Rename a table in MySQL

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.


Solution 1:

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.

Solution 2:

Please try

RENAME TABLE  `oldTableName` TO  `newTableName`

Solution 3:

The MySQL syntax for RENAME TABLE statement is the following:

RENAME TABLE <old_table_name> TO <new_table_name>

In your query, you've used group which is one of the keywords in MySQL. Try to avoid MySQL keywords for names while creating tables, field names and so on.

Solution 4:

ALTER TABLE old_table_name RENAME new_table_name;

or

RENAME TABLE old_table_name TO new_table_name;