何时在 iOS 中的 sqlite 中执行 Finalize 语句?
在iOS中使用sqlite时,什么时候执行finalize语句?
我需要在每次查询后完成语句吗?
重置 和 最终确定 和有什么不一样?
如果我重置了,我需要完成吗?
谢谢。
When using sqlite in iOS, when to do finalize statement ?
Do I need to finalize the statement after every query ?
What is the difference between reset and finalize ?
If I do reset, do I need to do finalize then ?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您完全完成一条语句时,可以使用 sqlite3_finalize() 函数,因为您执行了如下所示的一次性查询:
或者如果您完成了一条永远不会执行的准备好的语句再次需要(可能是因为您正在退出应用程序时进行清理)。
如果您创建了一条想要反复使用的语句(出于性能原因,因为准备一条语句的成本相当昂贵),您可以使用
sqlite3_reset()
来重置查询以便再次使用。在这种情况下,您不想最终确定,除非您决定永远不想重用该语句(同样,通常这是在拆除应用程序或特定对象期间)。仅在最后重置语句的查询示例如下:
You use the
sqlite3_finalize()
function when you are completely finished with a statement, either because you did a one-off query like the following:or if you are done with a prepared statement that you'll never need again (possibly because you're cleaning up on exiting the application).
If you've created a statement that you'll want to use over and over again (for performance reasons, because it is reasonably expensive to prepare a statement), you use
sqlite3_reset()
to reset the query so that it is ready to use again. You don't want to finalize in that case until you have decided that you'll never want to reuse that statement (again, usually this is during the teardown of your application or a particular object).An example of a query that only resets the statement at the end is as follows: