加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

SQLite从什么版本开始支持外键(Foreign Key)

发布时间:2020-12-12 19:48:32 所属栏目:百科 来源:网络整理
导读:http://androidren.com/index.php?qa=298qa_1=sqlite%E4%BB%8E%E4%BB%80%E4%B9%88%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E6%94%AF%E6%8C%81%E5%A4%96%E9%94%AE-foreign-key 从SQLite 3.6.19 开始支持 外键约束。 参考: http://sqlite.org/foreignkeys.html
sqlite> PRAGMA foreign_keys;
0
sqlite> PRAGMA foreign_keys = ON;
sqlite> PRAGMA foreign_keys;
1
sqlite> PRAGMA foreign_keys = OFF;
sqlite> PRAGMA foreign_keys;
0

Tip: If the command "PRAGMA foreign_keys" returns no data instead of a single row containing "0" or "1",then the version of SQLite you are using does not support foreign keys (either because it is older than 3.6.19 or because it was compiled withSQLITE_OMIT_FOREIGN_KEYorSQLITE_OMIT_TRIGGERdefined).

It is not possible to enable or disable foreign key constraints in the middle of amulti-statement transaction(when SQLite is not inautocommit mode). Attempting to do so does not return an error; it simply has no effect.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

http://androidren.com/index.php?qa=298&qa_1=sqlite%E4%BB%8E%E4%BB%80%E4%B9%88%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E6%94%AF%E6%8C%81%E5%A4%96%E9%94%AE-foreign-key

从SQLite 3.6.19 开始支持 外键约束。

参考:

http://sqlite.org/foreignkeys.html

Foreign key constraints are disabled by default (for backwards compatibility),so must be enabled separately for eachdatabase connection. (Note,however,that future releases of SQLite might change so that foreign key constraints enabled by default. Careful developers will not make any assumptions about whether or not foreign keys are enabled by default but will instead enable or disable them as necessary.) The application can also use aPRAGMA foreign_keysstatement to determine if foreign keys are currently enabled. The following command-line session demonstrates this:

    推荐文章
      热点阅读