Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I export a single trigger from mysql?

I need to re-create a single trigger in another mysql database - is there an easy way to export a single trigger?

like image 984
chris Avatar asked Dec 06 '12 15:12

chris


People also ask

How do I export a trigger?

To export a trigger, simply go to the “All Triggers” list and hover over a trigger, then click the “Export” button. A file with the same name will be automatically downloaded to your PC.

How do I save a trigger in MySQL?

First, specify the name of the trigger that you want to create after the CREATE TRIGGER keywords. Second, use AFTER INSERT clause to specify the time to invoke the trigger. Third, specify the name of the table on which you want to create the trigger after the ON keyword.

Does Mysqldump include triggers?

Mysqldump will attempt to dump all the triggers in your database by default. To be able to dump a table's triggers , you must have the TRIGGER privilege for the table.


1 Answers

What you want is a dump of single trigger of your db.

You can take inspiration from this article and from documentation.

For example, this command export only the stored procedures and triggers:

mysqldump --routines --no-create-info --no-data --no-create-db --skip-opt <database> > outputfile.sql

However, I do not think you can dump a single trigger. Since it's only one, maybe it's easier to recreate another dabatase.

like image 191
Luca Davanzo Avatar answered Oct 06 '22 01:10

Luca Davanzo