patternsqlModerate
Will mysqldump command also backup all the views that are present in DB or there is a special command for it?
Viewed 0 times
thepresentallaremysqldumpviewsalsowillthatspecial
Problem
I am trying to backup my entire database along with the views. I am going to use
Please suggest me an answer. Any help is greatly appreciated.
mysqldump command. I was wondering if that will copy all the views or I will have to use separate command for it.Please suggest me an answer. Any help is greatly appreciated.
Solution
There is no specific option for dumping views.
You can try the following:
You should be able to see the views. This indicates that when you dump databases, the view comes with it.
Another stunt you can try, just to get the views only, is this:
Give it a Try !!!
You can try the following:
mysqldump -h... -u... -p... --all-databases --routines --triggers --no-data > /root/MySQLDBSchema.sql
grep "CREATE ALGORITHM" /root/MySQLDBSchema.sqlYou should be able to see the views. This indicates that when you dump databases, the view comes with it.
Another stunt you can try, just to get the views only, is this:
mysql -uroot -prootpass AN -e"select concat('SHOW CREATE VIEW ',table_schema,'.',table_name,';') from information_schema.views" | sed 's/;/\\G/g' | mysql --uroot -prootpass > /root/MySQLDBViews.sqlGive it a Try !!!
Code Snippets
mysqldump -h... -u... -p... --all-databases --routines --triggers --no-data > /root/MySQLDBSchema.sql
grep "CREATE ALGORITHM" /root/MySQLDBSchema.sqlmysql -uroot -prootpass AN -e"select concat('SHOW CREATE VIEW ',table_schema,'.',table_name,';') from information_schema.views" | sed 's/;/\\G/g' | mysql --uroot -prootpass > /root/MySQLDBViews.sqlContext
StackExchange Database Administrators Q#11004, answer score: 15
Revisions (0)
No revisions yet.