I am trying to duplicate a table with triggers. I know that I've done this before, I just can't remember how I did it and where I learned how to do it. I've tried CREATE TABLE newname LIKE oldname
and CREATE TABLE newname AS oldname
, along with CREATE TABLE newname SELECT * FROM oldname
. None of those queries seem to be copying triggers. I've followed this, this, and this, and again, no luck. Is there any way that I can copy triggers when duplicating/creating a new table?
Asked
Active
Viewed 1,803 times
2
-
1https://dba.stackexchange.com/questions/145042/mysql-create-table-like-include-triggers – Paul Spiegel Mar 13 '18 at 19:23
-
Export the trigger into a textfile. Find and replace the table name. Then import the file. – Paul Spiegel Mar 13 '18 at 19:41
1 Answers
0
The short answer is: you cannot do this with a single sql statement.
The reason is that triggers are not part of the table, they are an entirely different object that happens to be related to a table.

Shadow
- 33,525
- 10
- 51
- 64