ORACLE隐含列
2015-11-03 10:44
519 查看
11G:
When you issue an
The following statements are examples of dropping columns from the
The first statement drops only the
The next statement drops both the
If you are concerned about the length of time it could take to drop column data from all of the rows in a large table, you can use the
queries or data dictionary views, and its name is removed so that a new column can reuse that name. All constraints, indexes, and statistics defined on the column are also removed.
To mark the
as unused, execute the following statement:
You can later remove columns that are marked as unused by issuing an
The data dictionary views
or
containing unused columns. The
of unused columns in the table.
For external tables, the
is transparently converted into an
Because external tables consist of metadata only in the database, the
performs equivalently to the
The
only action allowed on unused columns. It physically removes unused columns from the table and reclaims disk space.
In the
clause
to be applied after processing the specified number of rows, in this case 250. Checkpointing cuts down on the amount of undo logs accumulated during the drop column operation to avoid a potential exhaustion of undo space.
Removing Columns from Tables
When you issue an ALTER TABLE...DROP COLUMNstatement, the column descriptor and the data associated with the target column are removed from each row in the table. You can drop multiple columns with one statement.
The following statements are examples of dropping columns from the
hr.admin_emptable.
The first statement drops only the
salcolumn:
ALTER TABLE hr.admin_emp DROP COLUMN sal;
The next statement drops both the
bonusand
commcolumns:
ALTER TABLE hr.admin_emp DROP (bonus, commission);
Marking Columns Unused
If you are concerned about the length of time it could take to drop column data from all of the rows in a large table, you can use the ALTER TABLE...SET UNUSEDstatement. This statement marks one or more columns as unused, but does not actually remove the target column data or restore the disk space occupied by these columns. However, a column that is marked as unused is not displayed in
queries or data dictionary views, and its name is removed so that a new column can reuse that name. All constraints, indexes, and statistics defined on the column are also removed.
To mark the
hiredateand
mgrcolumns
as unused, execute the following statement:
ALTER TABLE hr.admin_emp SET UNUSED (hiredate, mgr);
You can later remove columns that are marked as unused by issuing an
ALTER TABLE...DROP UNUSED COLUMNSstatement. Unused columns are also removed from the target table whenever an explicit drop of any particular column or columns of the table is issued.
The data dictionary views
USER_UNUSED_COL_TABS,
ALL_UNUSED_COL_TABS,
or
DBA_UNUSED_COL_TABScan be used to list all tables
containing unused columns. The
COUNTfield shows the number
of unused columns in the table.
SELECT * FROM DBA_UNUSED_COL_TABS; OWNER TABLE_NAME COUNT --------------------------- --------------------------- ----- HR ADMIN_EMP 2
For external tables, the
SET
UNUSEDstatement
is transparently converted into an
ALTER
TABLE
DROP
COLUMNstatement.
Because external tables consist of metadata only in the database, the
DROP
COLUMNstatement
performs equivalently to the
SET
UNUSEDstatement.
Removing Unused Columns
The ALTER TABLE...DROP UNUSED COLUMNSstatement is the
only action allowed on unused columns. It physically removes unused columns from the table and reclaims disk space.
In the
ALTER TABLEstatement that follows, the optional
clause
CHECKPOINTis specified. This clause causes a checkpoint
to be applied after processing the specified number of rows, in this case 250. Checkpointing cuts down on the amount of undo logs accumulated during the drop column operation to avoid a potential exhaustion of undo space.
ALTER TABLE hr.admin_emp DROP UNUSED COLUMNS CHECKPOINT 250;
相关文章推荐
- Oracle查询锁表用户 释放被锁的表SQL 及超时120S的SQL 误删表还原
- oracle10g完全卸载及删除垃圾表
- 第一次写oracle触发器,记录一下
- oracle 游标
- oracle添加主键自增长
- 分享red hat linux 6上安装oracle11g时遇到的gcc: error trying to exec 'cc1': execvp: No such file or directory的问题处理过程
- Oracle EBS Patch Demo
- Oracle GoldenGate的思想天空--感悟OGG的本质
- oracle定时任务
- Oracle索引(转)
- Oracle学习路线图
- 转: Oracle中的物化视图
- 转: ORACLE索引介绍和使用
- Oracle数据库性能调优
- SQL获取第一条记录的方法(sqlserver、oracle、mysql数据库)
- 用Python操作Oracle
- win64位VMare11下redhat5.5安装oracle10g
- oracle数据库索引(转)
- Oracle物化视图的一般使用(转)
- Oracle 事务总结(转)