When I use mysqldump and the re-import the dump, the views become empty tables.
Is it possible to either
a) dump and then import views without turning them into empty tables?
or, if a is not possible,
b) exclude views from mysqldump with a wildcard, such as
mysqldump mydb --ignore-table=*views > mydb.sql
to exclude all views, if all views have names ending with the string “views”? (this part has been previously asked but remains unanswered: Ignore 'views' in mysql db backup using mysqldump)
Use
--compact --add-drop-tableand then manually adjust the dump file.Details:
--compactProduce more compact output. This option enables the
--skip-add-drop-table, --skip-add-locks, --skip-comments, --skip-disable-keys, and --skip-set-charsetoptions.Note:
Prior to MySQL 5.1.21, this option did not create valid SQL if the database dump contained views. The recreation of views requires the creation and removal of temporary tables and this option suppressed the removal of those temporary tables. As a workaround, use –compact with the –add-drop-table option and then manually adjust the dump file.