Mysql 导出视图、触发器
一:导出视图
SELECT CONCAT("DROP VIEW IF EXISTS `",TABLE_SCHEMA,"`.`",TABLE_NAME,"`;\nCREATE VIEW `", TABLE_SCHEMA,"`.`",TABLE_NAME,"` as ",VIEW_DEFINITION,";")
FROM information_schema.VIEWS
where TABLE_SCHEMA like '%XXX%' ;
二:导出触发器
SELECT CONCAT("DROP TRIGGER IF EXISTS `",TRIGGER_SCHEMA, "`.`", TRIGGER_NAME,"`;\nDELIMITER ;;\nCREATE TRIGGER `",TRIGGER_SCHEMA,"`.`",
TRIGGER_NAME,"` ",ACTION_TIMING," ",EVENT_MANIPULATION," ON
`",EVENT_OBJECT_SCHEMA,"`.`",EVENT_OBJECT_TABLE,"` FOR EACH ROW\n",ACTION_STATEMENT,";;\nDELIMITER ;") FROM information_schema.TRIGGERS;