如何在Oracle中查看今天编译的对象?

kup*_*upa 2 oracle

有没有办法找到今天编译的对象?

Jac*_*las 5

我认为timestampdba_objects是你所追求的:

create table t(id integer);
create function f return integer as
  n integer;
begin
  select count(*) into n from t;
  return n;
end;
/

select status, timestamp from user_objects where object_name='F';
STATUS  TIMESTAMP           
------- ------------------- 
VALID   2011-09-05:11:01:52 

insert into t(id) values (1);
select f() from dual;             -- ***no recompile needed***

select status, timestamp from user_objects where object_name='F';
STATUS  TIMESTAMP           
------- ------------------- 
VALID   2011-09-05:11:01:52 

alter table t add dummy integer;  -- ***invalidates f()***

select status, timestamp from user_objects where object_name='F';
STATUS  TIMESTAMP           
------- ------------------- 
INVALID 2011-09-05:11:01:52 

select f() from dual;             -- ***forces recompile***
select status, timestamp from user_objects where object_name='F';
STATUS  TIMESTAMP           
------- ------------------- 
VALID   2011-09-05:11:01:53       -- ***note the different timestamp*** 
Run Code Online (Sandbox Code Playgroud)

所以要获得今天编译的所有函数,例如:

select * 
from dba_objects
where to_date(substr(timestamp,1,10), 'yyyy-mm-dd')>=trunc(sysdate)
      and object_type='FUNCTION';
Run Code Online (Sandbox Code Playgroud)

- 编辑

使用它可能更安全last_ddl_time(请参阅下面的@Alex 评论),但需要注意的是,last_ddl_time授予和撤销也会更改。