Heim  >  Artikel  >  Datenbank  >  Oracle 检查表的数据变动

Oracle 检查表的数据变动

WBOY
WBOYOriginal
2016-06-07 16:59:031277Durchsuche

本知识点仅适用于Oracle 9i以上的版本。查看表的数据变动情况请使用SQL语句:select * from user_tab_modifications;user_tab_mo

本知识点仅适用于Oracle 9i以上的版本。

查看表的数据变动情况请使用SQL语句:select * from user_tab_modifications;

user_tab_modifications表的字段如下,从这个表中能够轻松找到表中做的修改,删除,增加记录的情况

注意以及使用方法:

1、但这张表不是实时更新的,默认情况15分钟更新一次,所以你更新一张表,可能在 user_tab_modifications里不能立刻体现出来。

2、想要实时查看也有办法实现,那就是在执行select * from user_tab_modifications之前先执行exec DBMS_STATS.FLUSH_DATABASE_MONITORING_INFO;这个存储过程目的就是立刻刷新异动信息的

3、当执行上面的存储过程出错时候,错误如下:

ERROR at line 1:

ORA-20000: Insufficient privileges

ORA-06512: at "SYS.DBMS_STATS", line 2148

ORA-06512: at "SYS.DBMS_STATS", line 14135

ORA-06512: at line 1

哈哈错误很明显,没有权限,那么提权!

4、为用户提权,,首先用管理员账号登陆,授予某个账户执行DBMS_STATS.FLUSH_DATABASE_MONITORING_INFO的权限。

grant analyze any to epplm(这里是你的用户名)

5、OK提权成功,那么返回到原账号(epplm),再执行exec DBMS_STATS.FLUSH_DATABASE_MONITORING_INFO,OK没问题

6、此时再执行select * from user_tab_modifications,记录出现了。

7、FLUSH_DATABASE_MONITORING_INFO存储过程之后,所有之前的操作都将被提交!

8、对于Oracle10i以及以上的版本,DML操作,都可以在该表中查到,因为这个功能默认是开启的,如果没有开启,可以通过这个方法开启:alter table t monitoring;

存储过程:

create or replace procedure Pro_Analyze_And_TableModify is

2 begin

3    dbms_output.put_line('开始执行,过程很长,请等待');

4    DBMS_STATS.FLUSH_DATABASE_MONITORING_INFO;--立刻刷新

5    insert into TableModifications select * from user_tab_modifications;--两个表结构一样

6    Pro_AnalyzeTables;--执行分析表(调用上一篇的存储过程)

7    dbms_output.put_line('执行成功');

8 end Pro_Analyze_And_TableModify;

linux

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:Oracle 的for update行锁语法!Nächster Artikel:Oracle 中的块结构