Skip to content

Instantly share code, notes, and snippets.

@emafriedrich
Created November 4, 2019 20:12
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 emafriedrich/ddd93c1988b885764b5098d8a75526bc to your computer and use it in GitHub Desktop.
Save emafriedrich/ddd93c1988b885764b5098d8a75526bc to your computer and use it in GitHub Desktop.
This command generate the commands for rename all table names from a database to another database schema.
SELECT CONCAT('RENAME TABLE ',table_schema,'.',table_name,
' TO ','new_database_name',table_name,';')
FROM information_schema.TABLES
WHERE table_schema LIKE 'old_database_name';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment