SQLite中的显式锁定机制 [英] Explicit locking mechanism in SQLite

查看:144
本文介绍了SQLite中的显式锁定机制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在向表中插入或更新行之前,我没有找到显式的sqlite锁定命令。 sqlite是否自己处理锁定机制?
http://sqlite.org/lockingv3.html 中描述的寻呼机模块处理锁定机制。但我不知道是否有任何用户可以使用来显式锁定表的命令。请指导。

I did not find explicit sqlite locking commands before inserting or updating rows into the table. Does sqlite handle the locking mechanism on it own? The pager module described in http://sqlite.org/lockingv3.html handles the locking mechanism. But I am not sure if there are any commands that the user can use to explicitly lock the tables. Please advice.

感谢

推荐答案

没有专门的sqlite命令来控制锁定。但是,您可以使用创建事务获取sqlite锁定数据库。例如:

As far as I know there are no dedicated sqlite commands to control locking. However you can get sqlite to lock the database using create transaction. For example:

BEGIN IMMEDIATE TRANSACTION;
...
COMMIT TRANSACTION;

BEGIN EXCLUSIVE TRANSACTION;
...
COMMIT TRANSACTION;

如果你阅读我链接的文档,你应该更好地了解 IMMEDIATE & EXCLUSIVE 交易。

If you read the documentation I linked you should get a better idea on the difference between IMMEDIATE & EXCLUSIVE transactions.

可能值得注意的是,sqlite中的锁适用于整个数据库,不同于其他sql数据库中的 LOCK TABLE 语句。

It might be worth noting that the locks in sqlite apply to the whole database and not just individual tables, unlike the LOCK TABLE statement in other sql databases.

这篇关于SQLite中的显式锁定机制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆