我找到了答案,但也许我想念一些东西。
我有2个表见下文。第一个表中的实体是从第二个表中引用的,但是当我尝试从第二个表中删除时,我得到Error: foreign key mismatch
。有触发器(此处未显示),但它们与DELETE
或cmdauth
无关。我不明白为什么不能删除行?
CREATE TABLE app (name TEXT, script TEXT, PRIMARY KEY(name));
CREATE TABLE env (name TEXT, PRIMARY KEY(name));
CREATE TABLE role (name TEXT, command TEXT, PRIMARY KEY(name,command));
CREATE TABLE cmdauth (groupname TEXT, rolename TEXT, appname TEXT, envname TEXT, FOREIGN KEY (appname) REFERENCES app(name), FOREIGN KEY (rolename) REFERENCES role(name), FOREIGN KEY (envname) REFERENCES env(name), PRIMARY KEY (groupname,rolename,appname,envname));
sqlite> select * from cmdauth where appname='app1' and groupname='admin' and envname='test' and rolename='restarter';
admin|restarter|app1|test
sqlite> delete from cmdauth where appname='app1' and groupname='admin' and envname='test' and rolename='restarter';
Error: foreign key mismatch
感谢您的帮助!
答案 0 :(得分:2)