Rename or change name of MySQL table

Posted July 4, 2006 by Quinn McHenry in 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.


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.

  • subrahmanyam

    It is very good.

    • jitendra

      yes really !!!

  • Senaia

    Thanks, thats what I need 🙂

    Dont we all love google 😀

  • Stone Deft

    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.

    • Ssss

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

      • Inyourface

        what was the necessity to use inappropriate language?!

  • mosab

    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….

  • MADP

    Giant of yours! thanks for the tip.

  • anonymouse

    Thanks! Very straight to the point.

  • fabio

    beautiful – thnx

  • Rik

    Great Thx, simple but effective!

  • Anonymous

    Very Impressive

  • hbunny

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

  • sasimkumar

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

  • Anonymous

    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?

  • Патрик Жданов

    Thanks! it worked!
    Gracias! Funcionó!

  • Vivekv2v

    good i got correct result form hire……..

  • Topik1

    so nice

  • Guest

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

  • Gaurav Havefunmedia

    Thanks for the one line solution…

  • abc

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

  • Abc

    Really man without the clutter got the butter

  • parwinder

    hw change the table name in mysql

    plz plz plz plz plz plz help me yr

  • Nagaraj

    Thanx its very use full….. 🙂

  • larry

    thanks, it is useful ! n_n

  • Bapuni

    Thanxs a lot

  • Patrick

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

  • Sukasol

    Excellent .

    This is what i wanted.

    Thanks a lot to share like this post.

    Please keep it up.


  • Ankit

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

  • umesh.n


  • suri


  • muzzamel

    Thank you very much

  • oweceej

    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.

  • Thaanuja Rathanyake

    Yes. it’s works properly after refresh

  • Bongo

    Thanks, it worked like a charm

  • md40

    thank you..