Backing Up Views with Mysql Dump

前端 未结 7 2460
有刺的猬
有刺的猬 2020-12-08 10:02

I want to back up only the Views with mysqldump.

Is this possible?

If so, how?

7条回答
  •  星月不相逢
    2020-12-08 10:44

    Backing up views over multiple databases can be done by just using information_schema:

    mysql --skip-column-names --batch -e 'select CONCAT("DROP TABLE IF EXISTS ", TABLE_SCHEMA, ".", TABLE_NAME, "; CREATE OR REPLACE VIEW ", TABLE_SCHEMA, ".", TABLE_NAME, " AS ", VIEW_DEFINITION, "; ") table_name from information_schema.views'
    

提交回复
热议问题