且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

外键死锁时如何删除记录?

更新时间:2023-01-29 16:41:05

您可以在一条语句中删除两行:

You can delete both rows in a single statement:

WITH x AS (
   DELETE FROM u WHERE uid = 176266
)
DELETE FROM p WHERE pid = 113116;

这是有效的,因为在语句的末尾检查了 IMMEDIATE 约束.该语句删除两行,并且在语句结束时满足所有完整性约束.

This works because IMMEDIATE constraints is checked at the end of the statement. The statement deletes both rows, and at the end of the statement all integrity constraints are fulfilled.