我能夠執行以下操作:
SQLite version 2.8.17
Enter ".help" for instructions
sqlite> create table a (aid integer primary key, name text);
sqlite> create table b (bid integer, aid integer, name text, foreign key(aid) references a(aid));
sqlite> insert into b values (1,1,'wtf');
sqlite> select * from b;
1|1|wtf
sqlite> select * from a;
sqlite>
在我看來,插入應該失敗,因為表 a 中沒有“1”(或任何 id,實際上)的 id 值。
我是否從根本上誤解了外鍵、sqlite 或兩者?
uj5u.com熱心網友回復:
SQLite 版本 2.8.17 (2005-12-19) 不支持外鍵。直到3.6.19才引入外鍵支持。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/365404.html
標籤:sqlite
