Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rename a table column in Oracle 10g

I would like to know: How to rename a table column in Oracle 10g?

like image 590
Arvind Lairenjam Avatar asked Dec 14 '12 12:12

Arvind Lairenjam


3 Answers

SQL> create table a(id number);

Table created.

SQL> alter table a rename column id to new_id;

Table altered.

SQL> desc a
 Name                                      Null?    Type
 ----------------------------------------- -------- -----------
 NEW_ID                                             NUMBER
like image 65
DazzaL Avatar answered Nov 04 '22 15:11

DazzaL


The syntax of the query is as follows:

Alter table <table name> rename column <column name> to <new column name>;

Example:

Alter table employee rename column eName to empName;

To rename a column name without space to a column name with space:

Alter table employee rename column empName to "Emp Name";

To rename a column with space to a column name without space:

Alter table employee rename column "emp name" to empName;
like image 36
Praveen Vinny Avatar answered Nov 04 '22 15:11

Praveen Vinny


alter table table_name rename column oldColumn to newColumn;
like image 20
Srinivas B Avatar answered Nov 04 '22 14:11

Srinivas B