我已经设置了两个表:
原文链接:https://www.f2er.com/sqlite/197662.htmlCREATE TABLE A ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,name TEXT ); CREATE TABLE B ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,id2 INTEGER,book TEXT,FOREIGN KEY(id2) REFERENCES A(id) );
将数据插入A后,它看起来像这样:
1 John 2 Amy 3 Peter
将数据插入B后,它看起来像这样:
1 1 Lord of the Rings 2 1 Catch 22 3 2 Sum of All Fears 4 3 Hunt for Red October
然后我执行以下语句:
delete from a where id=1;
我然后重新启动sqlite3并重试,但这次我先输入:
PRAGMA foreign_keys = 1;
它仍然无法正常工作……