DelphiFAQ Home Search:

How can I rename table names and column names in mysql

 

comments25 comments. Current rating: 5 stars (9 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;

Content-type: text/html

Comments:

You are on page 1 of 2, other pages: [1] 2
2007-02-28, 09:12:57
anonymous from United States  
Exactly what I needed - thanks
2007-05-16, 23:05:29
anonymous from India  
Thanks
2007-06-11, 23:22:50
anonymous  
rating
2008-01-09, 23:28:15
saeid.zebardast@gmail.com from Tehran, Iran  
rating
Thanks
2008-03-27, 08:56:16
anonymous from Germany  
thx
2008-05-20, 12:27:40
anonymous from United States  
a good tip.. thanks
2008-05-25, 08:18:14   (updated: 2008-05-25, 08:18:41)
dd from United States  
rating
Thanks, helped a lot since I am just learning SQL and using mySQL.
2008-09-26, 23:28:22
anonymous from Madras, India  
perfect
2008-10-24, 11:02:39   (updated: 2008-10-24, 11:04:22)
anonymous from Bangalore, India  
rating
Thank you very much
2008-12-11, 01:56:53
anonymous from South Africa  
I'm struggling to rename a column from a table without affecting the data in it using mysql console
2009-04-03, 12:29:42   (updated: 2009-04-03, 12:30:29)
anonymous from Madras, India  
thanks
2009-08-10, 01:54:37
anonymous from Mongolia  
tnx.I really want to learn mysql prefectly. berikbolt@yahoo.com
2010-01-13, 06:58:34
anonymous from India  
Thanks
2010-01-14, 18:17:48
anonymous from Canada  
go fuckurself fail wrong bullshit on table rename
2010-01-18, 01:39:07
anonymous from Mongolia  
tnx a lot
You are on page 1 of 2, other pages: [1] 2

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: