更新时间:2023-02-02 22:59:01
这可能不是你的意思正在寻找,但我个人从不使用级联删除。
如果我确实发现需要将主键表删除为外键约束,我首先删除所有带有该外键的行
即
This may not be what you are looking for, but personally I never use cascading deletes.
If I do find the need to delete the primary key table to a foreign key constraint, I first just delete all the rows with that foreign key
i.e.
delete from customersales where customerId = 23
delete from customer where customerid = 23
这样我控制住了,我不用担心关于某人不小心删除了他们不想要的一大堆记录!
that way I am in control, and I needn't worry about someone accidentally deleting a whole bunch of records they didn't mean to!