Truncate table對x bh的影響

2021-04-16 00:36:27 字數 1850 閱讀 9192

今天在做實驗的時候發現:truncate table後x$bh不會再記錄對此table塊的訪問,具體實驗如下:

sql>create table t3 ( a number);

table created.

sql>select object_id from dba_objects where object_name='t3';

object_id

----------

51560

sql>select obj,tch,dbarfil,dbablk from x$bh where obj=51560;

obj tch dbarfil dbablk

---------- ---------- ---------- ----------

51560 2 1 60465

sql>insert into t3 select level from dual connect by level<=1000;

1000 rows created.

sql>select obj,tch,dbarfil,dbablk from x$bh where obj=51560;

obj tch dbarfil dbablk

---------- ---------- ---------- ----------

51560 1 1 60467

51560 1 1 60466

51560 3 1 60465

sql>truncate table t3;

table truncated.

sql>select obj,tch,dbarfil,dbablk from x$bh where obj=51560;

no rows selected

sql>insert into t3 select level from dual connect by level<=1000;

1000 rows created.

sql>commit;

commit complete.

sql>select obj,tch,dbarfil,dbablk from x$bh where obj=51560;

no rows selected

但是如果table中沒有任何資料(只有乙個塊記錄段頭)時,x$bh就不會受truncate影響

sql>create table t4 (a number);

table created.

sql>select object_id from dba_objects where object_name='t4';

object_id

----------

51566

sql>select obj,tch,dbarfil,dbablk from x$bh where obj=51566;

obj tch dbarfil dbablk

---------- ---------- ---------- ----------

51566 1 1 60473

sql>truncate table t4;

table truncated.

sql>select obj,tch,dbarfil,dbablk from x$bh where obj=51566;

obj tch dbarfil dbablk

---------- ---------- ---------- ----------

51566 2 1 60473

本文**

TRUNCATE TABLE 清除表資料

刪除表中的所有行,而不記錄單個行刪除操作。語法truncate table name 引數name 是要截斷的表的名稱或要刪除其全部行的表的名稱。注釋truncate table 在功能上與不帶 where 子句的 delete 語句相同 二者均刪除表中的全部行。但 truncate table 比...

Truncate table 清除表內容

truncate table 刪除表中的所有行,而不記錄單個行刪除操作。truncate table 與沒有 where 子句的 delete 語句類似 但是,truncate table 速度更快,使用的系統資源和事務日誌資源更少。語法 table name 引數database name 資料庫...

使用 TRUNCATE TABLE 刪除所有行

若要刪除表中的所有行,則 truncate table 語句是一種快速 無日誌記錄的方法。truncate table 與不含有 where 子句的 delete 語句在功能上相同。但是,truncate table 速度更快,並且使用更少的系統資源和事務日誌資源。與 delete 語句相比,tru...