2017-05-10 33 views

回答

3

你可以看一下在user_objects,或all_objectsdba_objectslast_ddl_time如果你沒有連接作爲所有者:

select last_ddl_time 
from user_objects 
where object_type = 'TABLE' 
and object_name = '<your table name>' 

select last_ddl_time 
from dba_objects 
where object_type = 'TABLE' 
and owner = '<your table owner>' 
and object_name = '<your table name>' 

這會告訴你最後時間對桌子進行任何DDL;儘管如果稍後進行任何其他更改(例如約束,列修改等),那麼這可能不是列添加。請記住,所有者和表名稱需要與它們存儲在字典中的大小寫相同 - 通常爲大寫(除非使用帶引號的標識符)。

快速演示:

create table t42 (id number); 

Table T42 created. 

select to_char(last_ddl_time, 'YYYY-MM-DD hh24:MI:SS') as last_change 
from user_objects 
where object_type = 'TABLE' 
and object_name = 'T42'; 

LAST_CHANGE   
------------------- 
2017-05-10 11:12:18 

然後一段時間後...

alter table t42 add (new_column varchar(10)); 

Table T42 altered. 

select to_char(last_ddl_time, 'YYYY-MM-DD hh24:MI:SS') as last_change 
from user_objects 
where object_type = 'TABLE' 
and object_name = 'T42'; 

LAST_CHANGE   
------------------- 
2017-05-10 11:14:22 
1

聽起來你在這之後:

SELECT last_ddl_time 
FROM all_objects 
WHERE object_name = 'YOUR_TABLENAME' 
AND object_type = 'TABLE'; 
1

在Oracle 11g中& 12C我們可以啓用日誌記錄DLL

alter system set enable_ddl_logging=true; 

的DDL日誌文件數據是以XML格式寫入位於... \log\ddl