您可以使用內聯視圖(或類似的CTE)來查找每個模式的DDL時間,例如,使用聚合和窗口子句和過濾器的結果通過在外部查詢比較這些值:
select owner, object_name, last_ddl_time
from (
select owner, object_name, last_ddl_time,
max(case when owner = 'SC1' then last_ddl_time end)
over (partition by object_name) as sc1_time,
max(case when owner = 'SC2' then last_ddl_time end)
over (partition by object_name) as sc2_time
from all_objects
where object_type = 'VIEW'
and owner in ('SC1','SC2')
)
where sc1_time > sc2_time
order by 2,1,3;
你也可以用它來顯示兩個DDL倍並排側:
select object_name, sc1_time, sc2_time
from (
select owner, object_name,
max(case when owner = 'SC1' then last_ddl_time end)
over (partition by object_name) as sc1_time,
max(case when owner = 'SC2' then last_ddl_time end)
over (partition by object_name) as sc2_time
from all_objects
where object_type = 'VIEW'
and owner in ('SC1','SC2')
)
where sc1_time > sc2_time
and owner = 'SC1'
order by 1;
請提供樣品數據和所需的結果。 –