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.