1.11M Members

rename column

 
0
 

Hello,

What's the mysql syntax to rename column in a table?

I try this:

 ALTER TABLE static_content RENAME COLUMN title TO shorttext 

MySQL said: Documentation

#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 'COLUMN title TO shorttext' at line 1 
 
-1
 

alter table <tablename> rename column <oldname> to <newname>

Ex : ALTER TABLE emp RENAME COLUMN emp_name to employee_name;

 
1
 

@ling_tj, @anas.man: RENAME COLUMN is Oracle syntax, not MySQL.

 
0
 

To rename a column called "Column_Old" to "Column_New" in the table named "customer":

mysql> alter table customer change Column_Old Column_New int(3) unsigned;

So, when renaming a column, we need to provide the old column name first, then after the new column name.

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article