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.


About Quinn McHenry

Quinn was one of the original co-founders of Tech-Recipes. He is currently crafting iOS applications as a senior developer at Small Planet Digital in Brooklyn, New York.
View more articles by Quinn McHenry

The Conversation

Follow the reactions below and share your own thoughts.

39 Responses to “Rename or change name of MySQL table”

  1. November 20, 2008 at 5:53 am, subrahmanyam said:

    It is very good.


    • October 17, 2012 at 7:38 am, jitendra said:

      yes really !!!


  2. November 25, 2008 at 3:11 pm, Senaia said:

    Thanks, thats what I need :)

    Dont we all love google :D


  3. November 28, 2008 at 9:49 pm, Stone Deft said:

    Hey that was simple I thought it wouldn’t work but it did…


  4. December 13, 2008 at 3:40 pm, ben said:

    That did not work for me. Using MySQL 4.1.25.


    • August 29, 2010 at 6:36 pm, Ssss said:

      tum chutiya ho saale naya version use krne me ho rha hai tume pyar ho gaya hai 4.1 se..


      • November 04, 2010 at 2:20 pm, Inyourface said:

        what was the necessity to use inappropriate language?!


  5. December 17, 2008 at 4:10 pm, mosab said:

    thank you


  6. December 22, 2008 at 9:27 pm, hardik said:

    thx a lot smarty


  7. January 29, 2009 at 12:26 pm, xyz said:

    vey nice i’m impressed by the precise answer
    keep it up
    i wish i could get answers this way….


  8. February 15, 2009 at 4:44 pm, MADP said:

    Giant of yours! thanks for the tip.


  9. April 15, 2009 at 1:35 am, anonymouse said:

    Thanks! Very straight to the point.


  10. April 20, 2009 at 7:50 pm, fabio said:

    beautiful – thnx


  11. May 31, 2009 at 12:17 pm, Rik said:

    Great Thx, simple but effective!


  12. October 12, 2009 at 5:12 pm, Anonymous said:

    Very Impressive


  13. November 26, 2009 at 4:12 pm, hbunny said:

    thank you for this post, really helpful, and yes Senaia, thank God there’s google :)


  14. December 28, 2009 at 9:25 am, sasimkumar said:

    Thanks for the syntax and it is very useful for my learning …


  15. January 08, 2010 at 6:03 pm, Anonymous said:

    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?


  16. February 04, 2010 at 5:06 pm, Патрик Жданов said:

    Thanks! it worked!
    Gracias! Funcionó!


  17. June 16, 2010 at 1:25 pm, Vivekv2v said:

    good i got correct result form hire……..


  18. January 01, 2011 at 10:57 pm, Topik1 said:

    so nice


  19. January 26, 2011 at 3:56 am, Guest said:

    Thanks a lot…i was desperately searching for it..


  20. February 07, 2011 at 7:54 am, Gaurav Havefunmedia said:

    Thanks for the one line solution…


  21. March 31, 2011 at 10:40 am, abc said:

    not impressive because i want inside mysql……….not through code


  22. April 25, 2011 at 12:20 pm, Abc said:

    Really man without the clutter got the butter


  23. April 28, 2011 at 7:24 am, parwinder said:

    hw change the table name in mysql

    plz plz plz plz plz plz help me yr


  24. January 23, 2012 at 11:46 pm, Nagaraj said:

    Thanx its very use full….. :)


  25. March 13, 2012 at 6:50 pm, larry said:

    thanks, it is useful ! n_n


  26. March 22, 2012 at 2:43 am, Bapuni said:

    Thanxs a lot


  27. May 31, 2012 at 7:53 pm, Patrick said:

    Splendid! That was all I needed. Thank you very much and have a wonderful day, sir. Cheers from Holland.


  28. June 05, 2012 at 10:29 am, Sukasol said:

    Excellent .

    This is what i wanted.

    Thanks a lot to share like this post.

    Please keep it up.



  29. July 11, 2012 at 3:08 pm, Ankit said:

    Thnxx a tonneee
    This is what i was searching for since past 30 minutes :-p


  30. October 11, 2012 at 10:59 am, umesh.n said:



  31. December 15, 2012 at 1:02 am, suri said:



  32. April 18, 2013 at 11:23 pm, muzzamel said:

    Thank you very much


  33. April 24, 2013 at 7:47 am, oweceej said:

    Thanks for this tip, it was just what I was looking for. I don’t know much MySQL, so for a beginner it is useful.


  34. May 14, 2013 at 7:40 pm, Thaanuja Rathanyake said:

    Yes. it’s works properly after refresh


  35. July 16, 2013 at 6:20 am, Bongo said:

    Thanks, it worked like a charm


  36. October 04, 2013 at 6:49 am, md40 said:

    thank you..


Leave a Reply