Question

Is there any way to exclude views from mysql dump export?

I tried --ignore-table command. But this command recommand the parameters of table which i want to exclude.

I have 30 views in my database.

Is there any simple way to export only table (not views)?

Thanks

Was it helpful?

Solution

Based on the answer here, you should be able to pipe the table objects to mysqldump like:

mysql -u username INFORMATION_SCHEMA
  --skip-column-names --batch
  -e "select table_name from tables where table_type = 'BASE TABLE'
      and table_schema = 'database'"
  | xargs mysqldump -u username database
  > tables.sql

OTHER TIPS

Making it an answer from comment:-)

I use SQLyog from for this. You can select what table objects you would need like views,sp,triggers or events.. you can include or exclude with the dump.

The free version is available here: https://code.google.com/p/sqlyog/wiki/Downloads

I had to add another -p for the mysqldump command. This is what I ended up with:

mysql -u root -p INFORMATION_SCHEMA 
--skip-column-names --batch 
-e "select table_name from tables where table_type = 'BASE_TABLE' 
  and table_schema = 'my_database_name'" 
| xargs mysqldump -u root -p --opt --compress my_database_name 
| gzip -9 -c > my_database_name-tables.sql.gz

also optimises and compresses the dump + creates a gzip.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top