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

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Renaming a Column

Re: Renaming a Column

From: <exu_at_nnng.com>
Date: Wed, 14 Feb 2001 08:10:18 -0800
Message-ID: <F001.002B3F5C.20010214071151@fatcity.com>

Below are the steps and examples to rename a table:

  1. create a view of the table which you want to rename its column

vantive> desc salgrade;

 Name                                                                    Null?

    Type



 GRADE NUMBER
 LOSAL NUMBER
 HISAL NUMBER vantive> create view salgrade_vw as select * from salgrade;

View created.

2. create a new table with new column names, and select * from the view you just created.

vantive> create table salgrade_new (grade_new, losal_new, hisal_new)   2 as select * from salgrade_vw;

Table created.

Elapsed: 00:00:00.26
vantive> desc salgrade_new;

 Name                                                                    Null?

    Type



 GRADE_NEW
                                                                        NUMBER
 LOSAL_NEW
                                                                        NUMBER
 HISAL_NEW
                                                                        NUMBER

3. drop the table which you want to change its column name.

vantive> drop table salgrade;

Table dropped.

4. Rename the table which you created on step 3 to the table name which you dropped on step 3.
vantive> alter table salgrade_new rename to salgrade;

Table altered.

Elapsed: 00:00:00.02
vantive> desc salgrade;

 Name                                                                    Null?

    Type



 GRADE_NEW
                                                                        NUMBER
 LOSAL_NEW
                                                                        NUMBER
 HISAL_NEW
                                                                        NUMBER



By the way, you can also drop the view you created on step 2 now.

Good luck,

Eveleen

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: 
  INET: exu_at_nnng.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists

--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
Received on Wed Feb 14 2001 - 10:10:18 CST

Original text of this message

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