zoukankan      html  css  js  c++  java
  • TRUNCATE TABLE

    TRUNCATE TABLE [schema.] table
      [ {PRESERVE | PURGE} MATERIALIZED VIEW LOG ]
      [ {DROP [ ALL ] | REUSE} STORAGE ] ;

    STORAGE Clauses

    The STORAGE clauses let you determine what happens to the space freed by the truncated rows. The DROP STORAGE clause, DROP ALL STORAGE clause, and REUSE STORAGE clause also apply to the space freed by the data deleted from associated indexes.

    DROP STORAGE Specify DROP STORAGE to deallocate all space from the deleted rows from the table except the space allocated by the MINEXTENTS parameter of the table. This space can subsequently be used by other objects in the tablespace. Oracle Database also sets the NEXT storage parameter to the size of the last extent removed from the segment in the truncation process. This setting, which is the default, is useful for small and medium-sized objects. The extent management in locally managed tablespace is very fast in these cases, so there is no need to reserve space.

    DROP ALL STORAGE Specify DROP ALL STORAGE to deallocate all space from the deleted rows from the table, including the space allocated by the MINEXTENTS parameter. All segments for the table, as well as all segments for its dependent objects, will be deallocated.

    The DROP ALL STORAGE clause is available starting with Oracle Database 11g Release 2 (11.2.0.2).

    REUSE STORAGE Specify REUSE STORAGE to retain the space from the deleted rows allocated to the table. Storage values are not reset to the values when the table was created. This space can subsequently be used only by new data in the table resulting from insert or update operations. This clause leaves storage parameters at their current settings.

    This setting is useful as an alternative to deleting all rows of a very large table—when the number of rows is very large, the table entails many thousands of extents, and when data is to be reinserted in the future. TRUNCATE TABLE with REUSE STORAGE performs several orders of magnitude faster than deleting all rows, but has the following drawbacks:

    • You cannot roll back a TRUNCATE TABLE statement.

    • All cursors are invalidated.

    • You cannot flash back to the state of the table before the truncate operation.

    This clause is not valid for temporary tables. A session becomes unbound from the temporary table when the table is truncated, so the storage is automatically dropped.

    If you have specified more than one free list for the object you are truncating, then the REUSE STORAGE clause also removes any mapping of free lists to instances and resets the high-water mark to the beginning of the first extent.

  • 相关阅读:
    单链表的相关操作
    R学习-- 数组和矩阵
    UIButton 设置圆角 边框颜色 点击回调方法
    【独立开发人员er Cocos2d-x实战 007】使用Cocos2dx UserDefault.xml
    聊一聊多源最短路径问题(仅仅有5行代码哦)
    Android cookies正确的更新方式
    Android IntentService的使用和源代码分析
    Android应用之——最新版本号SDK V2.4实现QQ第三方登录
    嵌套路由
    我自己用
  • 原文地址:https://www.cnblogs.com/wwxbi/p/4175421.html
Copyright © 2011-2022 走看看