How to rename a table column in Oracle 10g

OracleOracle10g

Oracle Problem Overview


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

Oracle Solutions


Solution 1 - Oracle

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

Solution 2 - Oracle

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;

Solution 3 - Oracle

alter table table_name rename column oldColumn to newColumn;

Solution 4 - Oracle

suppose supply_master is a table, and

SQL>desc supply_master;


SQL>Name
 SUPPLIER_NO    
 SUPPLIER_NAME
 ADDRESS1       
 ADDRESS2       
 CITY           
 STATE          
 PINCODE  


SQL>alter table Supply_master rename column ADDRESS1 TO ADDR;
Table altered



SQL> desc Supply_master;
 Name                   
 -----------------------
 SUPPLIER_NO            
 SUPPLIER_NAME          
 ADDR   ///////////this has been renamed........//////////////                
 ADDRESS2               
 CITY                   
 STATE                  
 PINCODE                  

Solution 5 - Oracle

alter table table_name 
rename column old_column_name/field_name to new_column_name/field_name;

example: alter table student rename column name to username;

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionArvind LairenjamView Question on Stackoverflow
Solution 1 - OracleDazzaLView Answer on Stackoverflow
Solution 2 - OraclePraveen VinnyView Answer on Stackoverflow
Solution 3 - OracleSrinivas BView Answer on Stackoverflow
Solution 4 - OracleNarayanView Answer on Stackoverflow
Solution 5 - OracleGudddu kumarView Answer on Stackoverflow