views:

3603

answers:

3

Hi there In my database I have some tables and views. How can I export all the tables( and not the views ) from my database from command line?

+1  A: 

You can use mysqldump with the option --ignore-table to exclude the views individually. Or use mysqldump and remove the views with an application/manually. grep might be an option:

grep -v "CREATE VIEW" db.dump > db-without-views.dump
soulmerge
+3  A: 

The current implementation mysqldump won't create dumps without views -- and furthermore, (last time I checked) views are actually created twice -- once as a table, then the table is dropped and replaced with a view. So you can't just filter out the "CREATE VIEW" command, unless that behavior has been modified.

However, mysqldump will take a list of tables as parameters following the database name. Something like this:

mysqldump -ujoe -pmysecret joesdb posts tags comments users
tylerl
A: 

Backuping a single table from a database mysqldump -uUSERNAME -pPASWORD DATABASE TABLE_NAME --host=HOST_NAME > c:\TABLE_NAME.sql

Restoring a single table from a database dump mysql -uUSERNAME -pPASSWORD DATABASE --host=HOST_NAME < c:\TABLE_NAME.sql

Green Card