Tuesday, August 12, 2014

rename move database on MySQL

show tables from old_db;

rename table old_db.tableName1 to new_db.tableName1, old_db.tableName2 to new_db.tableName2, old_db.tableName3 to new_db.tableName3;

SELECT CONCAT('RENAME TABLE ',table_schema,'.',table_name,
' TO ','new_schema.',table_name,';')
FROM information_schema.TABLES
WHERE table_schema LIKE 'old_schema';

No comments: