Is it true I can’t edit a MySQL trigger, I have to drop it and create a new one?
Also, being a relative newcomer to triggers, it feels like they seem liable to causing ‘erroneous’ data. For example I might want a trigger to be fired (inserting data into another table) after one particular type of update query, but not others.
Any tips here gratefully received!
Edit: Yes, it is true that versions 5.n and 6.n of MySQL 5 & 6 implement
CREATE TRIGGERandDROP TRIGGERand nothing else. According to this hunk of Postgres documentation, there is not evenCREATE TRIGGERin SQL 92, so consider yourself lucky to have TRIGGER at all 🙂The Visual Studio MySQL plugin documentation has:
… which seems to do what you want. My guess is this is GUI sugar and behind the scenes you get a
DROP CREATE.As far as a trigger for some
UPDATEs and not others, SQL has exactly oneUPDATEper table. Put anIFclause at the start of yourUPDATEtrigger so that your logic – whatever you are doing in some of yourUPDATEs – is only executed when you think it is appropriate.