Skip to content

Instantly share code, notes, and snippets.

@jasny
Forked from michaelmior/rename-db.sh
Last active August 29, 2015 14:01
Show Gist options
  • Save jasny/f4487a2da5bf85542422 to your computer and use it in GitHub Desktop.
Save jasny/f4487a2da5bf85542422 to your computer and use it in GitHub Desktop.
#!/bin/sh
OLD_DB=$1
NEW_DB=$2
TABLES=`echo "SHOW TABLES IN $1;" | mysql -NB`
IFS="
"
for TABLE in $TABLES; do
$(echo "RENAME TABLE \`$1\`.\`$TABLE\` TO \`$2\`.\`$TABLE\`;" | mysql)
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment