Creating MySQL Triggers
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.
精彩评论