In mysql
I can create a trigger, and then show information about it like this:
mysql> show triggers like 'fooTrigger';
This command gives output that looks an awful lot like a select statement, with a row showing the matching trigger. Is it possible to update a column on the row it shows me?
For example, one column is named Statement
, and it defines what happens when the trigger is activated. Is it possible to change the Statement
field for fooTrigger
so the trigger does something different? Or do I need to drop
and re-create
the trigger?
To modify an existing trigger, double-click the node of the trigger to modify, or right-click this node and choose the Alter Trigger command from the context menu. Either of the commands opens the SQL Editor.
Answer: In MySQL, there's no statement to update or alter an existing trigger. If after trigger creation, you need to change the trigger. You can DROP the existing trigger using the DROP TRIGGER command and create a new one with the same name.
To destroy the trigger, use a DROP TRIGGER statement. You must specify the schema name if the trigger is not in the default schema: mysql> DROP TRIGGER test.
As of MySQL 5.5, you must drop and re-create the trigger.
It is not possible to update the Statement
column without dropping the trigger.
Documentation: CREATE TRIGGER DROP TRIGGER
You may also access information about triggers using the INFORMATION_SCHEMA tables:
SELECT * FROM INFORMATION_SCHEMA.TRIGGERS
But, as these tables are actually views, you can't use UPDATE
on them.
It's just a more convenient way to access and manipulate the information than using SHOW TRIGGERS.
Documentation: INFORMATION_SCHEMA.TRIGGERS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With