Backing Up Views with Mysql Dump

前端 未结 7 2461
有刺的猬
有刺的猬 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:43

    I would stick as closely as possible to the output of mysqldump like the OP asked, since it includes a slew of information about the view that can't be reconstructed with a simple query from the INFORMATION_SCHEMA.

    This is how I create a deployment view script from my source database:

    SOURCEDB="my_source_db"
    mysql $SOURCEDB --skip-column-names  -B -e \
    "show full tables where table_type = 'view'" \
    | awk '{print $1}' \
    | xargs -I {} mysqldump $SOURCEDB {} > views.sql
    

提交回复
热议问题