mysql on delete关键字_什么是MySQL的默认ON DELETE行为?

是的,这是正确的:

NO ACTION: […] InnoDB

rejects the delete or update operation

for the parent table.

RESTRICT: Rejects the delete or update

operation for the parent table.

Specifying RESTRICT (or NO ACTION) is

the same as omitting the ON DELETE or

ON UPDATE clause. […]

显然NO ACTION和RESTRICT是同义词。此外,由于它们在没有ON DELETE / UPDATE子句时使用,这是默认行为。

SET NULL: Delete or update the row from the parent table and set the

foreign key column or columns in the

child table to NULL. […]

如果外部列未声明为NOT NULL(或InnoDB不允许删除或更新),则将外部列设置为NULL。

CASCADE: Delete or update the row from the parent table and

automatically delete or update the

matching rows in the child table.

[…]

级联删除(或更新)外部列。

SET DEFAULT: This action is recognized

by the parser, but InnoDB rejects

table definitions containing ON DELETE

SET DEFAULT or ON UPDATE SET DEFAULT

clauses.

所以基本上你不能使用该选项。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值