我准备了
a fiddle which demonstrates the problem.
CREATE TABLE parent ( parent_id integer primary key ); CREATE TABLE child ( child_name TEXT primary key,parent_id integer REFERENCES parent (parent_id) ON DELETE CASCADE ); INSERT INTO parent VALUES (1); INSERT INTO child VALUES ('michael',1),('vanessa',1);
我想要一种删除子记录时删除CASCADE到父记录的方法.
例如:
DELETE FROM child WHERE child_name='michael';
这应该级联到父表并删除记录.