Created
September 11, 2014 14:00
-
-
Save carlosspohr/bce9392dbae0fd5c1815 to your computer and use it in GitHub Desktop.
Helper bash script to dump all missing tables from an incomplete database compared with complete database. Very useful when you have an outdated database or working on migrations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mysql -uroot -pyour-pass -e 'SELECT CONCAT(t1.TABLE_NAME, "") AS missing_tables FROM information_schema.TABLES t1 WHERE t1.table_schema = "complete_database" AND t1.TABLE_NAME NOT IN (SELECT t2.TABLE_NAME FROM information_schema.TABLES t2 WHERE t2.table_schema = "incomplete_database") ORDER BY t1.TABLE_NAME ASC' | grep -v missing_tables | xargs mysqldump --skip-add-drop-table -uroot -pyour-pass -d --routines complete_database > missing-tables.sql |
thanks god i'm not @carlosjrcabello
Author
ouaehoueha
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
oh my