开发者

Deleting Records in Joined Multiple Tables in a DataBase

How can I delete a particular record in a DataBase where 6 tables are join开发者_如何学运维ed among each other.


It is possible to create the FOREIGN KEY (with "ON DELETE CASCADE" action) Constraint(s) that will automatically remove records from the corresponding referenced tables. Take a look at the “FOREIGN KEY Constraints” Books Online / MSDN topic for more information.


Do it within a transaction. Referential integrity isn't checked until the transaction is closed:

begin;
delete from table1 where ...;
delete from table2 where ...;
delete from table3 where ...;
commit;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜