Databases InterBase (28) MS-SQL (5) mysql (36) Oracle (1)
Exchange Links About this site Links to us 
|
How can I rename table names and column names in mysql
11 comments. Current rating: (5 votes). Leave comments and/ or rate it.
If only a few changes are necessary, you can just go through a web administration tool like phpAdmin.
If you have many names to change, you could write a script (possibly even generate a script by a tool) and execute it like this:
mysql DATABASENAME -uUSERNAME -pPASSWORD <SCRIPTFILE
The script would contain the SQL commands as shown here:
 | |  | | alter table orgs change o_id org_id int(11);
alter table orgs change o_name org_name varchar(64);
rename table orgs organizations;
| |  | |  |
Comments:
|
|
|
|
thanks i have used it
|
|
|
|
|
Exactly what I needed - thanks
|
|
|
|
|
Thanks
|
|
|
|
|
|
2007-12-10, 01:36:20 (updated: 2007-12-10, 01:37:02) |
|
|
|
just be aware... if your table is large this can take a very long time!!!
(its not just a matter of changing column names - mysql has to mess about with EVERY row).
PS. i am not in Spain (go figure?!)
|
|
|
|
|
Thanks
|
|
|
|
|
thx
|
|
|
|
|
a good tip.. thanks
|
2008-05-25, 08:18:14 (updated: 2008-05-25, 08:18:41) |
|
|
|
Thanks, helped a lot since I am just learning SQL and using mySQL.
|
|
|
|
|
perfect
|
2008-10-24, 11:02:39 (updated: 2008-10-24, 11:04:22) |
|
|
|
Thank you very much
|
|