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 

Recommended Answers


RENAME is for tables.

ALTER TABLE static_content CHANGE COLUMN title shorttext VARCHAR(255)

Adjust the column type accordingly.

Jump to Post

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

Jump to Post

All 5 Replies

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

Ex : ALTER TABLE emp RENAME COLUMN emp_name to employee_name;

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.