Rename a Column

How to rename a column in a SQL table?

Questions by vimalkumarrai

Editorial / Best Answer

sravee123  

  • Member Since May-2008 | Jun 10th, 2008


ALTER TABLE table_name RENAME COLUMN old_name to new_name;

Ex: ALTER TABLE employee RENAME COLUMN eno to empno;

Showing Answers 1 - 2 of 2 Answers

ALTER TABLE TABLENAME RENAME COLUMN OLDCOLUMNNAME TO NEWCOLUMNNAME

[CODE]
SQL> DESC EMP;
 Name                            Null?    Type
 ------------------------------- -------- ----
 EMPNO                           NOT NULL NUMBER(4)
 ENAME                                    VARCHAR2(10)
 JOB                                      VARCHAR2(9)
 MGR                                      NUMBER(4)
 HIREDATE                                 DATE
 SAL                                      NUMBER(7,2)
 COMM                                     NUMBER(7,2)
 DEPTNO                                   NUMBER(2)

SQL>  ALTER TABLE EMP RENAME COLUMN HIREDATE TO JOINDATE;

Table altered.

SQL> DESC EMP
 Name                            Null?    Type
 ------------------------------- -------- ----
 EMPNO                           NOT NULL NUMBER(4)
 ENAME                                    VARCHAR2(10)
 JOB                                      VARCHAR2(9)
 MGR                                      NUMBER(4)
 JOINDATE                                 DATE
 SAL                                      NUMBER(7,2)
 COMM                                     NUMBER(7,2)
 DEPTNO                                   NUMBER(2)
[/CODE]

  Was this answer useful?  Yes

In ORACLE 9i ,no OPTION FOR CHANGING COLUMN NAME.If you want dispaly as like column nameeg: select empno,ename "EMPLOYEE NAME" from emp;regardskrishna

  Was this answer useful?  Yes

shriraam

  • Nov 3rd, 2008
 

Basically you dont have an option or a separate syntax for renaming a column in 9i, 10g.
But there is one such thing called column alias process can be done initially at the time of querying.

  Was this answer useful?  Yes

dj_dj_dj

  • Mar 19th, 2010
 

No doubt, alter table table_name rename column column_name to new_columnname ....


shows you the desired result....But mind you if you have installed registered Oracle software on your system, it is not possible to rename column once table is created.

  Was this answer useful?  Yes

yash thakkar

  • Jul 13th, 2011
 

EXEC sp_rename
@objname = 'TableName.OldColumnName',
@newname = 'NewColumnName',
@objtype = 'COLUMN'

  Was this answer useful?  Yes

namrata

  • Sep 14th, 2011
 


above answer not working in oracle 9i.........

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions