问题描述
是否可以确定上一次在Oracle中访问表的时间? 我正在尝试此操作,但这将不包括最后一次选择该表的时间.
Is it possible to determine when the last time a table was accessed in Oracle? I am trying this, but this will not include when was the last time the table was selected.
select * from dba_objects;
推荐答案
根据@KD的答案,我开发了此查询来检测未使用的表:
From @KD 's answer I've developed this query to detect unused tables:
select a.obj#, b.object_name, b.owner, b.object_type, b.timestamp
from dba_hist_seg_stat a, dba_objects b
where a.obj# = b.object_id
and b.owner = 'YOUR_SCHEMA_NAME'
and object_name = 'A_TABLE_NAME'
order by timestamp desc
由于此查询使用SYS用户视图,因此您必须具有运行它的特殊特权.如果有它们,则可以查看dba_hist_XXX视图,或者仅查看此处使用的视图中的其余列:您具有有关读取,写入,锁定等信息.
Since this query makes use of SYS user views, you must have special privileges to run it. If you have them, you can have a look at dba_hist_XXX views, or only have a look at the rest of the columns in the views used here: you have info about reads, writes, locks and many more.
编辑:感谢@APC的警告. DBA_HIST_XXX是Diagnostics Pack中的视图,需要特殊许可.
EDIT: Thanks to @APC for the warning. DBA_HIST_XXX are views from Diagnostics Pack that require special license.
这篇关于上次在oracle中访问表的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!