开发者

Creating MySQL Triggers

开发者 https://www.devze.com 2023-03-24 12:24 出处:网络
I have so开发者_StackOverflowme experience with mysql but have never created a trigger.I have two tables in my database, books and series.The series has a primary key series_id that is also a foriegn

I have so开发者_StackOverflowme experience with mysql but have never created a trigger. I have two tables in my database, books and series. The series has a primary key series_id that is also a foriegn key constraint on books. I want to create a trigger so that when a row in the series table is updated, all books related to that series are also deleted. I understand the basic mysql syntax to do this, but I'm not sure how to make a trigger out of this.

I've tried reading through some tutorials, but I'm still not clear. The tutorials all create test tables...do I need to do this? Also, how do I pass a parameter, or can I?

Help is greatly appreciated.


I don't know that you'll need to explicitly create a trigger for this. Just have the foreign key use the cascade on delete. The documentation for it is here.

0

精彩评论

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