Michael Peter Michael Peter - 1 year ago 99
SQL Question

Rename a column in mysql

I am trying to rename a column in mysql community server 5.5.27 using this SQL

Alter table tablename rename column oldcolname to newcolname;

I also tried

Alter table tablename rename oldcolname to newcolname;

But it says error check the Manual that corresponds to your Mysql server version

Answer Source

Use the following query:

ALTER TABLE tableName CHANGE "oldcolname" "newcolname" datatype(length);

The RENAME function is used in Oracle databases.

ALTER TABLE tableName RENAME COLUMN "oldcolname" TO "newcolname" datatype(length);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download