Rename or change name of MySQL table
If you change your mind and want to rename an existing MySQL table, with or without data in it, it is no problem. One simple command will change the table’s name.
To change the name of an existing table first to second, use this command as a user with adequate privileges:
RENAME TABLE first TO second;
It is good DBA manners to make sure that no one and no program are using this table before making the name change.










subrahmanyam said on November 20, 2008
It is very good.
Senaia said on November 25, 2008
Thanks, thats what I need :)
Dont we all love google :D
Stone Deft said on November 28, 2008
Hey that was simple I thought it wouldn’t work but it did…
ben said on December 13, 2008
That did not work for me. Using MySQL 4.1.25.
mosab said on December 17, 2008
thank you
hardik said on December 22, 2008
thx a lot smarty
xyz said on January 29, 2009
vey nice i’m impressed by the precise answer
keep it up
i wish i could get answers this way….
:-)
MADP said on February 15, 2009
Giant of yours! thanks for the tip.
anonymouse said on April 15, 2009
Thanks! Very straight to the point.
fabio said on April 20, 2009
beautiful – thnx
Rik said on May 31, 2009
Great Thx, simple but effective!
Anonymous said on October 12, 2009
Very Impressive
hbunny said on November 26, 2009
thank you for this post, really helpful, and yes Senaia, thank God there’s google :)
sasimkumar said on December 28, 2009
Thanks for the syntax and it is very useful for my learning …
Anonymous said on January 8, 2010
Thanks for the advice to “make sure that no one and no program are using this table before making the name change.” Are there commands to do this? Could it possibly have been a joke, implying that we should telephone hundreds of users, email dozens of developers, make a list of who is logged on to what (which security people frown on doing), restrict logins for a week, and stop all processes? Doesn’t the atomic nature of the rename mean that it is safe to update a second table, rename the first table to backup and the new table to the first table atomically?
Патрик Жданов said on February 4, 2010
Thanks! it worked!
Gracias! Funcionó!
Vivekv2v said on June 16, 2010
good i got correct result form hire……..
Ssss said on August 29, 2010
tum chutiya ho saale naya version use krne me ho rha hai tume pyar ho gaya hai 4.1 se..
Inyourface said on November 4, 2010
what was the necessity to use inappropriate language?!
Topik1 said on January 1, 2011
so nice
Guest said on January 26, 2011
Thanks a lot…i was desperately searching for it..
Gaurav Havefunmedia said on February 7, 2011
Thanks for the one line solution…
abc said on March 31, 2011
not impressive because i want inside mysql……….not through code
Abc said on April 25, 2011
Really man without the clutter got the butter
parwinder said on April 28, 2011
hw change the table name in mysql
plz plz plz plz plz plz help me yr
Nagaraj said on January 23, 2012
Thanx its very use full….. :)