Renaming a table in MySQL
Posted July 2nd, 2008 in MySql
Sometimes you need to rename a table in MySQL. You either run an SQL query to do this or do it with phpMyAdmin if you don't want to bother remembering the SQL to do so. This post looks at how to rename a table in MySQL either with a SQL query or using phpMyAdmin.
The example SQL below renames the MySQL table "tablename" to "tablename_renamed":
RENAME TABLE tablename TO tablename_renamed
To rename a MySQL table with phpMyAdmin, select the database then table, and click the "Operations" tab. Then put the new name into the text box labelled "rename table to" and click the "Go" button. The relevent buttons etc are highlighted with red circles in the screenshot below.

After clicking the "Go" button the table will be renamed and the same page as shown above will be loaded again, showing the rename query that was executed.
Related posts:
- How to enable remote access to a MySQL database server (Wednesday, April 1st 2009)
- Maximum length for MySQL TEXT field types (Wednesday, February 4th 2009)
- How to tell which storage engine a MySQL table uses (Tuesday, January 13th 2009)
- Rename multiple tables in MySQL (Saturday, January 10th 2009)
- Insert multiple records into MySQL with a single query (Wednesday, December 3rd 2008)
- Cross Table Update with MySQL (Monday, March 1st 2004)

Comments
blog comments powered by Disqus