sqlite foreign key mismatch 外键配置错误

前端之家收集整理的这篇文章主要介绍了sqlite foreign key mismatch 外键配置错误前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
 
foreign key mismatch
原来sqlite建表的时候,不会报外键约束错误,只有当你要删除的时候,才会报错误


sqlite> PRAGMA foreign_keys = ON;
设置外键级联有效;


我检查了我的建表语句,果然外键约束是错误的。

官网上是这样较我们的。

  • The parent table does not exist,or
  • The parent key columns named in the foreign key constraint do not exist,or
  • The parent key columns named in the foreign key constraint are not the primary key of the parent table and are not subject to a unique constraint using collating sequence specified in the CREATE TABLE,or
  • The child table references the primary key of the parent without specifying the primary key columns and the number of primary key columns in the parent do not match the number of child key columns.
参考: http://www.sqlite.org/foreignkeys.html

猜你在找的Sqlite相关文章