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 

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

Ex : ALTER TABLE emp RENAME COLUMN emp_name to employee_name;

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 developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.