IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Silly Mysql question...
Is there a way to rename mysql tables en masse? I need to merge three databases into one, which means I need to append an identifier to each table in each database before importing them into their new home... I can do rename tables one at a time in phpmyadmin, but that's taking quite a long time...
"We are all born originals -- why is it so many of us die copies?"
- Edward Young
New Wouldn't it be easier to...
Dump and reload? Or to create a new table import all the records and then drop the tables?

Sure it takes a bit more space, but still it'd be a might bit easier. At least I'd believe it to be.
--
[link|mailto:greg@gregfolkert.net|greg],
[link|http://www.iwethey.org/ed_curry|REMEMBER ED CURRY!] @ iwethey
PGP key: 1024D/B524687C 2003-08-05
Fingerprint: E1D3 E3D7 5850 957E FED0  2B3A ED66 6971 B524 687C
Alternate Fingerprint: 09F9 1102 9D74  E35B D841 56C5 6356 88C0
Alternate Fingerprint: 455F E104 22CA  29C4 933F 9505 2B79 2AB2
New Scripting solution
You can do it via a script. Create a file with:

RENAME TABLE OldTable1 TO NewTable1;
RENAME TABLE OldTable2 To NewTable2;

and so on. Then do:

mysql DatabaseName -uUsername -pPassword ScriptFile

from the command line to run the script against the database.

You can use the information schema tables to pull all of the table names:
SELECT table_name FROM INFORMATION_SCHEMA.TABLES
WHERE table_schema = 'DB_Name'

Jay
     Silly Mysql question... - (cwbrenn) - (2)
         Wouldn't it be easier to... - (folkert)
         Scripting solution - (JayMehaffey)

Not CRRRRRRAP!
75 ms