Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to rename the column name of the oracle table?

Re: How to rename the column name of the oracle table?

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Mon, 13 Sep 1999 09:14:52 -0400
Message-ID: <PPjcN3HmUtPJFJsc9knDp0AQG3wj@4ax.com>


A copy of this was sent to wy3141_at_my-deja.com (if that email address didn't require changing) On Mon, 13 Sep 1999 11:13:18 GMT, you wrote:

> I want to rename the column name of the table!
>but I don't want to drop it and recreate it
>because it has some other dependencies (roles,
>constraints)?

you cannot rename a column.

If you want, you can rename the TABLE and create a view that 'renames' the column. for example:

tkyte_at_8.0> desc emp

 Name                            Null?    Type
 ------------------------------- -------- ----
 EMPNO                           NOT NULL NUMBER(4)
 ENAME                                    VARCHAR2(10)
 JOB                                      VARCHAR2(9)
 MGR                                      NUMBER(4)
 HIREDATE                                 DATE
 SAL                             NOT NULL NUMBER(7,2)
 COMM                                     NUMBER(7,2)
 DEPTNO                                   NUMBER(2)

tkyte_at_8.0> rename emp to emp_table
  2 /

Table renamed.

tkyte_at_8.0> create view emp   2 as
  3 select empno employee_number, ename, job, mgr, hiredate, sal, comm, deptno   4 from emp_table;

View created.

tkyte_at_8.0> desc emp;

 Name                            Null?    Type
 ------------------------------- -------- ----
 EMPLOYEE_NUMBER                 NOT NULL NUMBER(4)
 ENAME                                    VARCHAR2(10)
 JOB                                      VARCHAR2(9)
 MGR                                      NUMBER(4)
 HIREDATE                                 DATE
 SAL                             NOT NULL NUMBER(7,2)
 COMM                                     NUMBER(7,2)
 DEPTNO                                   NUMBER(2)


You'll need to fix up the grants (eg: revoke them on emp_table and give them on emp) but you can get that from the DD pretty easily.

>
> Thanks in advance!
>
>
>
>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.

--
See http://govt.us.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'... Current article is "Part I of V, Autonomous Transactions" updated June 21'st  

Thomas Kyte                   tkyte_at_us.oracle.com
Oracle Service Industries     Reston, VA   USA

Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Mon Sep 13 1999 - 08:14:52 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US