The truncate operation changes the DATA_OBJECT_ID.

Source: Internet
Author: User

In Oracle, The OBJECT_ID in the following table is the same as that in DATA_OBJECT_ID.

However, the expression of DATA_OBJECT_ID after truncate changes. This feature can be used to determine whether the table has been truncate.

Note: (database link, FUNCTION, PROCEDURE, SEQUENCE, VIEW) There is no DATA_OBJECT_ID.

Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.1.0
Connected as report

SQL> SELECT t. table_name, t. last_analyzed, t. num_rows
2 FROM USER_TABLES t
3 WHERE t. table_name = 't2 ';

TABLE_NAME LAST_ANALYZED NUM_ROWS
----------------------------------------------
T2 16:56:17 3

-- OBJECT_ID of T2 is the same as DATA_OBJECT_ID

SQL> SELECT object_name, object_type, object_id, data_object_id
2 FROM USER_OBJECTS
3 WHERE object_name = 't2 ';

OBJECT_NAM OBJECT_TYPE OBJECT_ID DATA_OBJECT_ID
--------------------------------------------------------------
T2-table 75567 75567

SQL> truncate table T2;
Table truncated

SQL> analyze table t2 compute statistics;
Table analyzed

-- After truncate is performed on table T2, The OBJECT_ID is not changed, and the DATA_OBJECT_ID is changed from 75567 to 76592.

SQL> SELECT object_name, object_type, object_id, data_object_id
2 FROM USER_OBJECTS
3 WHERE object_name = 't2 ';
OBJECT_NAM OBJECT_TYPE OBJECT_ID DATA_OBJECT_ID
-----------------------------------------------------
T2-table 75567 76592

SQL>

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.