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
答案解析:
The effects of using this command are as follows:
• The table is marked as empty by setting the high-water mark (HWM) to the beginning of the table, making its rows unavailable. D对
• No undo data is generated and the command commits implicitly because TRUNCATE TABLE is a DDL command. E对。
• Corresponding indexes are also truncated.(索引也会清空) A对
• A table that is being referenced by a foreign key cannot be truncated. C错。
• The delete triggers do not fire when this command is used. B错。
(delete trigger 里面的内容不会执行,但对象仍然存在)
truncate--相应的 index 也会被 truncate,执行 truncate 会产生非常少量的 undo 信息或者
不产生,HWM(高水位标记)会恢复到第一个使用段,使用区、使用块,HWM 这时应该是第二个块
Using TRUNCATE
You can delete all rows of the table
using theTRUNCATE
statement. For example, the following statement truncates theemp
table:
Using the TRUNCATE
statement provides a fast, efficient method for deleting all rows from a table or cluster.A
TRUNCATE
statement does not generate any undo information and it commits immediately.It is a DDL statement and cannot be rolled back. ATRUNCATE
statement
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 theDROP 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 toDELETE
statements if auditing is enabled. Instead, a single audit record is generated for theTRUNCATE
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 the DELETE
statement or drop and re-create the table.
TheTRUNCATE
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 forMINEXTENTS
. Freed extents are then returned to the system and can be used by other objects. -
DROP
ALL
STORAGE
drops the segment. In addition to theTRUNCATE
TABLE
statement,DROP
ALL
STORAGE
also applies to theALTER
TABLE
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.TRUNCATE TABLE emp DROP ALL STORAGE; -
REUSE STORAGE
specifies that all space currently allocated for the table or cluster remains allocated to it. For example, the following statement truncates theemp_dept
cluster, leaving all extents previously allocated for the cluster available for subsequent inserts and deletes:TRUNCATE CLUSTER emp_dept REUSE STORAGE;