ITPub博客

首页 > 数据库 > Oracle > dba_objects中3个时间戳的区别

dba_objects中3个时间戳的区别

原创 Oracle 作者:banana_62 时间:2017-06-20 00:32:36 0 删除 编辑

CREATED:对象创建时间

11gR2数据库对象创建在2011年9月17号,不是很懂,oracle的某些时间设定是非常有趣的。

LAST_DDL_TIME:在对象上执行最后一次ddl的时间,也包括授权时间。

TIMESTAMP:Timestamp for the specification of the object (character data),对象说明(字符型数据)的创建时间,立马想到comment

SQL> select created,last_ddl_time,timestamp from dba_objects where object_name='TAB1';

CREATED     LAST_DDL_TIME TIMESTAMP

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

2017-06-19 15:57:16 2017-06-19 15:57:34 2017-06-19:15:57:16

SQL> comment on table smith.tab1 is 'for test';

Comment created.

SQL> select created,last_ddl_time,timestamp from dba_objects where object_name='TAB1';

CREATED     LAST_DDL_TIME TIMESTAMP

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

2017-06-19 15:57:16 2017-06-19 15:57:34 2017-06-19:15:57:16

期待的timestamp并没有发生改变。这里的specification很难理解,我们来试试其他的方法。

SQL> create view smith.view1 as select * from smith.tab1;

View created.

SQL> select created,last_ddl_time,timestamp from dba_objects where object_name='VIEW1';

CREATED     LAST_DDL_TIME TIMESTAMP

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

2017-06-19 23:13:18 2017-06-19 23:13:18 2017-06-19:23:13:18

SQL> create or replace view smith.view1 as select * from smith.tab1;

View created.

SQL> select created,last_ddl_time,timestamp from dba_objects where object_name='VIEW1';

CREATED     LAST_DDL_TIME TIMESTAMP

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

2017-06-19 23:13:18 2017-06-19 23:16:41 2017-06-19:23:13:18

SQL> create or replace view smith.view1 as select a from smith.tab1;

View created.

SQL> select created,last_ddl_time,timestamp from dba_objects where object_name='VIEW1';

CREATED     LAST_DDL_TIME TIMESTAMP

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

2017-06-19 23:13:18 2017-06-19 23:17:34 2017-06-19:23:13:18

SQL> alter table smith.tab1 add b int;

Table altered.

SQL> select created,last_ddl_time,timestamp from dba_objects where object_name='VIEW1';

CREATED     LAST_DDL_TIME TIMESTAMP

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

2017-06-19 23:13:18 2017-06-19 23:17:34 2017-06-19:23:13:18

上面的测试分别执行了重建view,更改view定义但view结果不变,更改view基础表但view结果不变,timestamp都没有变化,可以这样理解:只要对象的结构描述不变,timestamp就不会变(这也加深了我对specification这个单词的理解)。
我们在更改
view的基表时,last_ddl_time没有变化,也就是说last_ddl_time记录的是在当前对象ddl语句执行的时间。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31461640/viewspace-2140983/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2017-05-18

  • 博文量
    71
  • 访问量
    65037