Truncate and data_object_id

yyp2009發表於2014-07-01

預設的,一個表當進行truncate 表時DATA_OBJECT_ID將增加1;
但是當此表有一個索引時,進行truncate 表時DATA_OBJECT_ID將增加2:

SQL>
SQL> create table x ( x number );

Table created.

SQL> select object_id, data_object_id, last_ddl_time, created from user_objects where object_name = 'X';

 OBJECT_ID DATA_OBJECT_ID LAST_DDL_TIM CREATED
---------- -------------- ------------ ------------
    779899         779899 01-JUL-14    01-JUL-14

SQL>  truncate table x;

Table truncated.

SQL>  select object_id, data_object_id, last_ddl_time, created from user_objects where object_name = 'X';

 OBJECT_ID DATA_OBJECT_ID LAST_DDL_TIM CREATED
---------- -------------- ------------ ------------
    779899         779899 01-JUL-14    01-JUL-14

SQL> insert into x values ( 1 );

1 row created.

SQL> commit;

Commit complete.

SQL> select count(1) from x;

  COUNT(1)
----------
         1

SQL>  select object_id, data_object_id, last_ddl_time, created from user_objects where object_name = 'X';

 OBJECT_ID DATA_OBJECT_ID LAST_DDL_TIM CREATED
---------- -------------- ------------ ------------
    779899         779899 01-JUL-14    01-JUL-14

SQL> truncate table x;

Table truncated.

SQL>  select object_id, data_object_id, last_ddl_time, created from user_objects where object_name = 'X';

 OBJECT_ID DATA_OBJECT_ID LAST_DDL_TIM CREATED
---------- -------------- ------------ ------------
    779899         779900 01-JUL-14    01-JUL-14

SQL> truncate table x;

Table truncated.

SQL> select object_id, data_object_id, last_ddl_time, created from user_objects where object_name = 'X';

 OBJECT_ID DATA_OBJECT_ID LAST_DDL_TIM CREATED
---------- -------------- ------------ ------------
    779899         779900 01-JUL-14    01-JUL-14

SQL>  insert into x values ( 1 );

1 row created.

SQL> select object_id, data_object_id, last_ddl_time, created from user_objects where object_name = 'X';

 OBJECT_ID DATA_OBJECT_ID LAST_DDL_TIM CREATED
---------- -------------- ------------ ------------
    779899         779900 01-JUL-14    01-JUL-14

SQL> commit;

Commit complete.

SQL> select object_id, data_object_id, last_ddl_time, created from user_objects where object_name = 'X';

 OBJECT_ID DATA_OBJECT_ID LAST_DDL_TIM CREATED
---------- -------------- ------------ ------------
    779899         779900 01-JUL-14    01-JUL-14

SQL> truncate table x;

Table truncated.

SQL> select object_id, data_object_id, last_ddl_time, created from user_objects where object_name = 'X';

 OBJECT_ID DATA_OBJECT_ID LAST_DDL_TIM CREATED
---------- -------------- ------------ ------------
    779899         779901 01-JUL-14    01-JUL-14

SQL>
SQL>
SQL>
SQL> create index kk on x(x);

Index created.

SQL>  select count(1) from x;

  COUNT(1)
----------
         0

SQL> insert into x values ( 1 );

1 row created.

SQL> select object_id, data_object_id, last_ddl_time, created from user_objects where object_name = 'X';

 OBJECT_ID DATA_OBJECT_ID LAST_DDL_TIM CREATED
---------- -------------- ------------ ------------
    779899         779901 01-JUL-14    01-JUL-14

SQL> commit;

Commit complete.

SQL> select object_id, data_object_id, last_ddl_time, created from user_objects where object_name = 'X';

 OBJECT_ID DATA_OBJECT_ID LAST_DDL_TIM CREATED
---------- -------------- ------------ ------------
    779899         779901 01-JUL-14    01-JUL-14

SQL> truncate table x;

Table truncated.

SQL> select object_id, data_object_id, last_ddl_time, created from user_objects where object_name = 'X';

 OBJECT_ID DATA_OBJECT_ID LAST_DDL_TIM CREATED
---------- -------------- ------------ ------------
    779899         779904 01-JUL-14    01-JUL-14

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/13750068/viewspace-1200843/,如需轉載,請註明出處,否則將追究法律責任。

相關文章