Skip to content

Instantly share code, notes, and snippets.

@budda
Created January 20, 2013 00:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save budda/4576064 to your computer and use it in GitHub Desktop.
Save budda/4576064 to your computer and use it in GitHub Desktop.
A nice snippet to generate the SQL statements to move each individual table over to a new database - aka database renaming for MySQL. $1 and $2 are source and target respectively
SELECT concat('RENAME TABLE $1.',table_name, ' TO $2.',table_name, ';')
FROM information_schema.TABLES
WHERE table_schema='$1';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment