Oracle last update time (dba_objects)

Article Directory

Scenes

  • Want to know tables, views, stored procedures and other time of the last update?

in conclusion

Oracle 12c official document-all_objects

SELECT t.last_ddl_time, 
       t.*
  FROM dba_objects t
 WHERE t.owner = ''
   AND t.object_name = '';

Please note:

dab_objects、 all_objects、 user_objects: DDL 语句最后一个编译的时间
1. 对象进行了编译(如: create or replace)
2. 包含 grantrevoke 语句
3. 包含 truncate 语句

Extra knowledge points of truncate

  1. The database table is composed of: segment, area, block
  2. truncate is equivalent to "destroying" the previous'segment header', generating a
    new'segment header' corresponding to data_object_id in dba_objects (will change)

Demo

CREATE TABLE scott.table_test (
  ID   NUMBER,
  NAME VARCHAR2(30)
);

-- 请注意:insert、update、delete 是 DML 语句,不会引起 last_ddl_time 变化
INSERT INTO scott.table_test(ID, NAME) VALUES(1, '瑶瑶');
INSERT INTO scott.table_test(ID, NAME) VALUES(2, '悠悠');
INSERT INTO scott.table_test(ID, NAME) VALUES(3, '倩倩');
COMMIT;

Test statement:

GRANT SELECT ON scott.table_test TO hr;
REVOKE SELECT ON scott.table_test FROM hr;

TRUNCATE TABLE scott.table_test;

SELECT t.last_ddl_time, 
       t.*
  FROM dba_objects t
 WHERE t.owner = 'SCOTT'
   AND t.object_name = 'TABLE_TEST';

Test Results:
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_34745941/article/details/107054956