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

Home -> Community -> Usenet -> c.d.o.tools -> Re: How to drop a column?

Re: How to drop a column?

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 29 Jun 2001 08:36:06 -0700
Message-ID: <9hi79602b8o@drn.newsguy.com>

In article <9hi4k1$cum$1_at_stargate1.inet.it>, "Alessio" says...
>
>Hi to all, i'm a newbie!
>Which is the sintax for dropping a column of a table?
>It is possible to drop a col?
>thanks,Alessio
>
>

why does no one use a version....

in Oracle8i, you can drop or set unused a column (drop rewrites, unused "flag" deletes the column)

tkyte_at_TKYTE816> 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)

tkyte_at_TKYTE816> alter table emp drop column deptno;

Table altered.

tkyte_at_TKYTE816> alter table emp set unused (comm);

Table altered.

tkyte_at_TKYTE816> 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)



In 8.0 and before, you would rename the table and create a view that is named as the table was that does not select out that column (sort of like setting UNUSED)

--
Thomas Kyte (tkyte@us.oracle.com)             http://asktom.oracle.com/ 
Expert one on one Oracle, programming techniques and solutions for Oracle.
http://www.amazon.com/exec/obidos/ASIN/1861004826/  
Opinions are mine and do not necessarily reflect those of Oracle Corp 
Received on Fri Jun 29 2001 - 10:36:06 CDT

Original text of this message

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