Académique Documents
Professionnel Documents
Culture Documents
1)create table
2)add column
3)modify column
4)rename column
5)drop column
6)UNUSED OPTION
[oracle@oracle10g ~]$ export ORACLE_SID=test
[oracle@oracle10g ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Sun May 26 20:09:28 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> conn hr/hr
Connected.
SQL> create table tab_edit (id number, name varchar2(20));
Table created.
SQL> alter table tab_edit add dept_id number;
Table altered.
SQL> desc tab_edit
Name
Null?
----------------------------------------- -------ID
NAME
DEPT_ID
Type
---------------------------NUMBER
VARCHAR2(20)
NUMBER
Type
---------------------------NUMBER
VARCHAR2(20)
NUMBER
NUMBER(10)
Type
---------------------------NUMBER
VARCHAR2(20)
NUMBER
NUMBER(10)
Type
---------------------------NUMBER
VARCHAR2(20)
NUMBER
**UNUSED COLUMNS
SQL> alter table tab_edit set unused column dept_num;
Table altered.
SQL> desc tab_edit
Name
Null?
----------------------------------------- -------ID
NAME
SQL> select * from tab_edit;
ID NAME
---------- -------------------1 Mohan
To drop unused columns:
SQL> alter table tab_edit drop unused columns;
Table altered.
--Flashback table to before drop.
Type
---------------------------NUMBER
VARCHAR2(20)