Skip to content

How Oracle Rename Column

  • by

ALTER TABLE RENAME COLUMN

To rename a column, we need to do it through ALTER TABLE.

Let's see a table.

SQL> desc employees;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 EMPLOYEE_ID                               NOT NULL NUMBER(6)
...

In this case, we'd like to change the column name from EMPLOYEE_ID into EMP_ID as long as the new column name does not conflict with others in this table.

Next, we issue the command ALTER TABLE RENAME COLUMN.

SQL> alter table employees rename column employee_id to emp_id;

Table altered.

Let's check the final result.

SQL> desc employees;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 EMP_ID                                    NOT NULL NUMBER(6)
...

Please note that, we can't change the column name if the table is in READ ONLY mode.

If you're looking for a solution to change the order and position of columns, there're several ways to do it.

Leave a Reply

Your email address will not be published. Required fields are marked *