OCP 1Z0 052 167

来源:互联网 发布:算法导论有第四版吗? 编辑:程序博客网 时间:2024/06/02 06:06
167. Which  three  descriptions  are  correct  about  the  effects  of  the TRUNCATE  command  on  a  table? 
(Choose three.) 
A.The corresponding indexes for the table are also truncated. 
B.Delete triggers on the table are fired during the execution of the TRUNCATE command. 
C.The child table is truncated when the TRUNCATE command is applied on the parent table. 
D.The high-water mark (HWM) is set to point to the first usable data block in the table segment. 
E.No undo or very little undo data is generated during the execution of the TRUNCATE command. 
Answer: ADE  

truncate 是常用命令,可以快速的删掉全表数据并释放对应空间。

但在生产环境中要慎用,因为truncate命令删掉的数据不能回滚,也不能闪回。

http://docs.oracle.com/cd/E11882_01/server.112/e25494/general.htm#ADMIN11533

Using TRUNCATE

You can delete all rows of the table using the TRUNCATE statement. For example, the following statement truncates the emp table:

TRUNCATE TABLE emp;

Using the TRUNCATE statement provides a fast, efficient method for deleting all rows from a table or cluster.TRUNCATE statement does not generate any undo information and it commits immediately. It is a DDL statement andcannot be rolled back. A TRUNCATEstatement does not affect any structures associated with the table being truncated (constraints and triggers) or authorizations. ATRUNCATE statement also specifies whether space currently allocated for the table is returned to the containing tablespace after truncation.

You can truncate any table or cluster in your own schema. Any user who has the DROP ANY TABLE system privilege can truncate a table or cluster in any schema.

Before truncating a table or clustered table containing a parent key, all referencing foreign keys in different tables must be disabled. A self-referential constraint does not have to be disabled.

As a TRUNCATE statement deletes rows from a table,triggers associated with the table are not fired. Also, a TRUNCATE statement does not generate any audit information corresponding to DELETE statements if auditing is enabled. Instead, a single audit record is generated for the TRUNCATE statement being issued.

A hash cluster cannot be truncated, nor can tables within a hash or index cluster be individually truncated. Truncation of an index cluster deletes all rows from all tables in the cluster. If all the rows must be deleted from an individual clustered table, use theDELETE statement or drop and re-create the table.

The TRUNCATE statement has several options that control whether space currently allocated for a table or cluster is returned to the containing tablespace after truncation.

These options also apply to any associated indexes. When a table or cluster is truncated,all associated indexes are also truncated. The storage parameters for a truncated table, cluster, or associated indexes are not changed as a result of the truncation.

These TRUNCATE options are:

  • DROP STORAGE, the default option, reduces the number of extents allocated to the resulting table to the original setting for MINEXTENTS. Freed extents are then returned to the system and can be used by other objects.

  • DROP ALL STORAGE drops the segment. In addition to the TRUNCATE TABLE statement, DROP ALL STORAGE also applies to the ALTERTABLE TRUNCATE (SUB)PARTITION statement. This option also drops any dependent object segments associated with the partition being truncated.

    DROP ALL STORAGE is not supported for clusters.


0 0
原创粉丝点击