Influence of truncate table on x $ BH

Source: Internet
Author: User
Guidance:
During the experiment today, we found that x $ BH after truncate table won't record the access to this table block. The specific experiment is as follows:
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 rows created.
SQL> select OBJ, tch, dbarfil, dbablk from x $ BH where OBJ = 51560;
OBJ tch dbarfil dbablk
----------------------------------------
51560 1 60467
51560 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 rows created.
SQL> commit;
Commit complete.
SQL> select OBJ, tch, dbarfil, dbablk from x $ BH where OBJ = 51560;
No rows selected
However, if the table does not contain any data (only one block record segment header), x $ BH will not be affected by 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 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

This article is transferred from
Http://woodnan.itpub.net/post/37055/457768

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.