一:导出视图
SELECT CONCAT("DROP VIEW IF EXISTS `",TABLE_SCHEMA,"`.`",TABLE_NAME,"`;
CREATE 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,"`;
DELIMITER ;;
CREATE TRIGGER `",TRIGGER_SCHEMA,"`.`",
TRIGGER_NAME,"` ",ACTION_TIMING," ",EVENT_MANIPULATION," ON
`",EVENT_OBJECT_SCHEMA,"`.`",EVENT_OBJECT_TABLE,"` FOR EACH ROW
",ACTION_STATEMENT,";;
DELIMITER ;") FROM information_schema.TRIGGERS;