获取package的last_ddl_time问题

You have TWO objects in DBA_OBJECTS for a package, the package and the package body. If the interface doesn't change, LAST_DDL_TIME isn't updated for the package - but is for the package body.
ORACLE-SQL> @foo
Package created.
Package body created.
ORACLE-SQL> select object_name, object_type
  2            
ORACLE-SQL>
ORACLE-SQL> ed
Wrote file afiedt.buf

  1  select object_name, object_type, last_ddl_time
  2  from user_objects
  3* where object_name = 'FOO'
ORACLE-SQL> /

OBJECT_NAME
------------------------------------------------------------------------
--------
OBJECT_TYPE        LAST_DDL
------------------- --------
FOO
PACKAGE         22:10:05
FOO
PACKAGE BODY        22:10:06
ORACLE-SQL> save pack
Created file pack.sql
ORACLE-SQL> ed foo
[ some change to the package body]
ORACLE-SQL> @foo
Package created.
Package body created.
ORACLE-SQL> @pack
OBJECT_NAME
------------------------------------------------------------------------
--------
OBJECT_TYPE        LAST_DDL
------------------- --------
FOO
PACKAGE         22:10:05
FOO
PACKAGE BODY        22:11:38
ORACLE-SQL>
Be aware that the last_ddl_time is updated for grants so the date value may not reflect an actual code change but may be the result of just a grant.  My test shows only the specification date gets changed.

UT1 > select object_type, to_char(last_ddl_time,'YYYYMMDD HH24:MI:SS') LTIME
  2  from dba_objects
  3  where object_name = 'DBA_MSG'
  4  and object_type like 'PACKAGE%'
  5  /

OBJECT_TYPE        LTIME
------------------ -----------------
PACKAGE            20090728 16:32:17
PACKAGE BODY       20090120 15:37:15

UT1 > grant execute on mark.dba_msg to public
  2  /

Grant succeeded.

UT1 > select object_type, to_char(last_ddl_time,'YYYYMMDD HH24:MI:SS') LTIME
  2  from dba_objects
  3  where object_name = 'DBA_MSG'
  4  and object_type like 'PACKAGE%'
  5  /

OBJECT_TYPE        LTIME
------------------ -----------------
PACKAGE            20090728 16:36:01
PACKAGE BODY       20090120 15:37:15
posted @ 2009-08-17 08:10  道场  阅读(883)  评论(0编辑  收藏  举报