我有4个不同的表,我想删除一行,但它说:id仍然从表"部件"中引用。如何从表中删除汽车专用汽车(例如id = 10)并删除所有数据而不丢弃所有表和数据?我用Delete Restrict创建了表。
Table Car:
variables
Table Repair:
variables,
car_id integer NOT NULL REFERENCES car(id) ON UPDATE CASCADE ON DELETE RESTRICT
Table Parts:
variables,
repair_id integer NOT NULL REFERENCES repair(id) ON UPDATE CASCADE ON DELETE RESTRICT
Table Shop:
variables, part_id integer NOT NULL REFERENCES part(id) ON UPDATE CASCADE ON DELETE RESTRICT
答案 0 :(得分:1)
您自己设置ON DELETE RESTRICT
,因此如果仍然引用它会限制删除。您必须在事务drop existing FK
中添加REFERENCES car(id) ON UPDATE CASCADE ON DELETE CASCADE
新内容,然后您就可以删除级联...