053试题 96 - shrink space compact

题目:

96.Examine the following command:
SQL> ALTER TABLE booking SHRINK SPACE COMPACT;
Which activity is performed when the preceding command is executed?
A. The shrink operation touches every block in the BOOKING table
B. The high-water mark (HWM) for the BOOKING table is shifted from its original position
C. The progress of the shrink operation is saved in the bitmap blocks of the BOOKING table
D. The data manipulation language (DML) triggers on the BOOKING table are executed because the shrink operation is internally handled by the INSERT/DELETE operation

参考答案 C
解析
题目意思是,对表booking执行了shrink space compact命令。问执行该命令时候执行那个活动?
高水位线是不会调整的。所以B错误。
使用了compact参数,Oracle数据库对段空间进行碎片化,压缩表行,但将高水位的重置和空间的重新分配推迟到将来。如果您有可能跨操作的长时间运行的查询,并试图从已回收的块中读取数据,则此选项非常有用。碎片整理和压缩结果保存到磁盘上,因此不必在第二阶段重新进行数据移动。所以C正确。
您可以在非高峰时间重新发出收缩空间子句,而不使用COMPACT子句,以完成第二阶段。 所以A错误。
D选项的意思是说,因为shrink操作,在表内部进行了insert/delete操作,这个操作触发了触发器。这个说法是错误的。

 


参考文档:

https://docs.oracle.com/cd/E11882_01/server.112/e25494/schema.htm#ADMIN10161

You can shrink space in a table, index-organized table, index, partition, subpartition, materialized view, or materialized view log. You do this using ALTER TABLE, ALTER INDEX, ALTER MATERIALIZED VIEW, or ALTER MATERIALIZED VIEW LOG statement with the SHRINK SPACE clause.

Two optional clauses let you control how the shrink operation proceeds:

  • The COMPACT clause lets you divide the shrink segment operation into two phases. When you specify COMPACT, Oracle Database defragments the segment space and compacts the table rows but postpones the resetting of the high water mark and the deallocation of the space until a future time. This option is useful if you have long-running queries that might span the operation and attempt to read from blocks that have been reclaimed. The defragmentation and compaction results are saved to disk, so the data movement does not have to be redone during the second phase. You can reissue the SHRINK SPACE clause without the COMPACT clause during off-peak hours to complete the second phase.

  • The CASCADE clause extends the segment shrink operation to all dependent segments of the object. For example, if you specify CASCADE when shrinking a table segment, all indexes of the table will also be shrunk. (You need not specify CASCADE to shrink the partitions of a partitioned table.) To see a list of dependent segments of a given object, you can run the OBJECT_DEPENDENT_SEGMENTS procedure of the DBMS_SPACE package.

As with other DDL operations, segment shrink causes subsequent SQL statements to be reparsed because of invalidation of cursors unless you specify the COMPACT clause.

END

上一篇:Java8新特性 - Lambda 表达式


下一篇:人工智能基础1