开发者

Mysql BEFORE UPDATE trigger activation time

开发者 https://www.devze.com 2022-12-21 12:12 出处:网络
I have two InnoDB tables: CREATE TABLE master( id INTEGER UNSIGNED NOT NULL auto_increment PRIMARY KEY );

I have two InnoDB tables:

CREATE TABLE master(
   id INTEGER UNSIGNED NOT NULL auto_increment PRIMARY KEY
);

CREATE TABLE details(
   id INTEGER UNSIGNED NOT NULL auto_increment PRIMARY KEY, 
   master_id INTEGER UNSIGNED NOT NULL, CONSTRAINT `byMasterId` 
   FOREIGN KEY (`master开发者_JAVA技巧_id`) REFERENCES `master`(`id`) ON UPDATE CASCADE ON DELETE CASCADE 
);

And I need a BEFORE UPDATE trigger on master table to do some validation (and cancel an update in some cases). Do cascade changes in details table occur after BEFORE UPDATE trigger?


Yes, the "before update" trigger runs before the update on the master table, and the cascade happens after the update on the master table.

0

精彩评论

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