Rename a table in MySQL

299

Renaming a table is not working in MySQL

RENAME TABLE group TO member;

The error message is

#1064 - You have an error in your SQL syntax; check the manual that corresponds
        to your MySQL server version for the right syntax to use near 'group 
        RENAME TO member' at line 1

The query is working fine on other tables for me, but not with the table group.

This question is tagged with mysql database table-rename

~ Asked on 2012-09-29 06:01:54

The Best Answer is


497

group is a keyword (part of GROUP BY) in MySQL, you need to surround it with backticks to show MySQL that you want it interpreted as a table name:

RENAME TABLE `group` TO `member`;

added(see comments)- Those are not single quotes.

~ Answered on 2012-09-29 06:06:14


135

Please try

RENAME TABLE  `oldTableName` TO  `newTableName`

~ Answered on 2012-09-29 06:39:34


Most Viewed Questions: