Simple script to move all tables from one database to another. Please don't use this in production as it could fail horribly. Also, RENAME table doesn't work on views, so they won't be migrated.
This file contains 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
|TABLES=`echo "SHOW TABLES IN $1;" | mysql -NB`|
|for TABLE in $TABLES; do|
|$(echo "RENAME TABLE \`$1\`.\`$TABLE\` TO \`$2\`.\`$TABLE\`;" | mysql)|
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Depending on your database engine, foreign keys will point to the OLD_DB, even after the RENAME TABLE.