All Forums Database
ywjcjj 36 posts Joined 06/08
09 Jun 2008
what is the easiest way to change column name

If i want to change column name from 'ABC' to 'ABCD', what is the easiest way to do it. and if the column is one of the primary index, how could i do it?

joedsilva 505 posts Joined 07/05
12 Jun 2008

you can do an ALTER TABLE mytbl RENAME COLUMN oldnme TO newnme;However there are restrictions, like you can't rename a column if it's part of an index (for PI you will have to drop and recreate the table, for SI, drop indexes and then rename, create the SI again ...)For the complete list of restrictions, lookup the "Renaming Table Columns" section in data definitions manual.

ywjcjj 36 posts Joined 06/08
12 Jun 2008

Thank you. That works fine.

vsatsang 1 post Joined 05/09
19 May 2009

Just to clarify, the word "column" should not be in the statement.

lokesh.bisp 1 post Joined 02/12
04 May 2012

ALTER TABLE mytbl RENAME COLUMN oldnme TO newnme;

 

not use column keyword here 

You must sign in to leave a comment.