Rename or change name of MySQL table

Contributor Icon Contributed by qmchenry Date Icon July 4, 2006  
Tag Icon Tagged: MySQL

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.

Previous recipe | Next recipe |
 
  • subrahmanyam
    It is very good.
  • Thanks, thats what I need :)

    Dont we all love google :D
  • Hey that was simple I thought it wouldn't work but it did...
  • ben
    That did not work for me. Using MySQL 4.1.25.
  • thank you
  • hardik
    thx a lot smarty
  • xyz
    vey nice i'm impressed by the precise answer
    keep it up
    i wish i could get answers this way....
    :-)
  • Giant of yours! thanks for the tip.
  • anonymouse
    Thanks! Very straight to the point.
  • fabio
    beautiful - thnx
  • Rik
    Great Thx, simple but effective!
  • azra_ayu
    Very Impressive
blog comments powered by Disqus