需要转储mysql触发器

时间:2015-01-19 12:44:55

标签: mysql

我必须将触发器从生产转储到本地服务器。有没有办法像sql一样转储它?

我需要这样的东西:

DROP TRIGGER IF EXISTS triggername; 
CREATE TRIGGER triggername 
AFTER DELETE ON tablename 
FOR EACH ROW 
BEGIN
body of trigger;
END

1 个答案:

答案 0 :(得分:0)

我发现自己的解决方案不明确但是有效。

我刚刚创建了查询:

select CONCAT("DROP TRIGGER IF EXISTS ",t.TRIGGER_NAME,"; CREATE TRIGGER ",t.TRIGGER_NAME," ",t.ACTION_TIMING," ",t.EVENT_MANIPULATION," ON ",t.EVENT_OBJECT_TABLE," FOR EACH ROW ",t.ACTION_STATEMENT,";") FROM information_schema.triggers t

这可以通过轻松添加到其他机器。