Skip to content Skip to sidebar Skip to footer

Execute Interdependent Views From Mysqldump Backup

mysqldump creates a dump with the tables (and views) listed alphabetically. When there are foreign key relationships between the tables this is not very convenient, however, the pr

Solution 1:

Recent versions of mysqldump, when dumping whole databases, solve things this way: for every view in the database, they first create an empty table with the same structure, then they create the views, dropping each placeholder table before creating a view. It seems that replacing a table with a view won't harm views that depend on it.

I know about this because this approach has another flaw, which bit me: rows in views may contain more data than rows in tables, so some of the placeholder tables cannot be created, causing some dumps to be unrestorable without manual intervention. For this reason, a topological sorting of views would be preferable, although it might require some work.

Post a Comment for "Execute Interdependent Views From Mysqldump Backup"