父表是
CREATE TABLE BHEAD ( ID INTEGER primary key asc,DESCR TEXT,LINECTR INT,UNITCTR INT)
儿童桌是
CREATE TABLE BDET ( ID INTEGER primary key asc,BID INTEGER,BCODE TEXT,QTY INTEGER,FOREIGN KEY (BID) REFERENCES BHEAD(ID) ON DELETE CASCADE )
我也执行sql PRAGMA foreign_keys = ON;
但它不起作用;当我从BHEAD中删除一行时,其在BDET中的相关行没有消失……
那是为什么?
解决方法
您使用的是什么版本的sqlite?
请参阅:Foreign Keys.
In order to use foreign key constraints in sqlite,the library must be compiled with neither sqlITE_OMIT_FOREIGN_KEY or sqlITE_OMIT_TRIGGER defined.