这是一个简单的shema:
sqlite> .schema recordtypes
CREATE TABLE recordtypes (record_id text primary key);
sqlite> .schema headers
CREATE TABLE headers (header_id text primary key);
sqlite> .schema record_to_headers
CREATE TABLE record_to_headers (id INTEGER, recordid TEXT, headerid TEXT, FOREIGN KEY(recordid) REFERENCES recordtypes(record_id), FOREIGN KEY(headerid) REFERENCES headers(header_id));
然后我将值插入然后recordtypes
插入record_to_headers
:
sqlite> insert into recordtypes values("test");
sqlite> insert into record_to_headers values (1, "test", "yeah");
然后我从表中删除“测试”,recordtypes
期望它也从record_to_headers
表中删除,但这永远不会发生:
sqlite> delete from recordtypes where record_id = "test";
sqlite> select * from recordtypes;
sqlite> select * from record_to_headers;
1|test|yeah
如果我从表中删除值,我需要行为,recordtypes
它也会从record_to_header
表中删除。请建议如何这样做。非常感谢。