Oracle 10g中的Logmnr的使用是本文我们主要要介绍的内容,我们知道,在Oracle9i中,Logmnr工具是DBA用来找回被剔除数据的好措施,利用Logmnr能够告终以下的任务:
1、查明数据库的改变登记,可能是举行改变分析,如有的用户猜忌自己的利用有什么问题,发生了许多的失手,能够用Logmnr来分析这些事务,看看究竟发生了些什么事情。
2、查明并修改用户的误垄断,如有的用户一不当心误剔除非某个表,然而并不确认,这个时候就能够利用Logmnr来分析是谁厉行的DML可能是DDL垄断。
3、找回失落的数据,当不能利用flashback可能利用flashback受到局限的时候,能够琢磨利用Logmnr工具来找回数据,这个时候,只必需有归档日志即可。
Logmnr工具包括的内容与数据字典
dbms_logmnr_d包:用于提取字典消息到表,包括三个过程:
(1)add_logfile:用来增加/剔除用于分析的日志文件。
(2)start_logmnr:用来开启日志分析,而且在9i/10g中,能够开启许多不同的分析选项。
(3)end_logmnr:用来终止分析会话,它将回收LogMiner所挪借的内存。
万一等闲用户想利用以上的包,定然目前sys中授权能力够利用,如:
sys用户厉行授权:
SQL> grant execute on dbms_logmnr to scott;
与LogMiner相干的数据字典如下:
u v$logmnr_dictionary:LogMiner可能利用的数据字典消息。
u v$logmnr_parameters:目前LogMiner所设定的参数消息。
u v$logmnr_logs:目前用于分析的日志列表。
u v$logmnr_contents:日志分析收获。
Logmnr分析过程演示
创立一张表,然后插入一些数据,再剔除这些数据。
连接到:
class="dp-xml">
- Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
- With the Partitioning, OLAP and Data Mining options
- SQL> alter system archive log current;
- 系统已改动。
- SQL> create table mytesttab as select * from scott.dept;
- 表已创立。
- SQL> insert into mytesttab values(80,'IT','WA');
- 已创立 1 行。
- SQL> insert into mytesttab values(90,'MGR','YR');
- 已创立 1 行。
- SQL> commit;
- 提交告终。
- SQL> delete from mytesttab;
- 已剔除6行。
- SQL> commit;
- 提交告终。
- SQL> alter system archive log current;
- 系统已改动。
然后找出垄断过程登记的日志文件
- D:/oracle/flash_recovery_area/MYORACLE/ARCHIVELOG/2007_08_11目录下的O1_MF_1_4_3CVHLKJM_.ARC文件,我们必需对这个文件举行分析处理。
- SQL> exec sys.dbms_logmnr.add_logfile(LogFileName=>'D:/oracle/flash_recovery_area/MYORACLE/ARCHIVELO
- G/2007_08_11/O1_MF_1_4_3CVHLKJM_.ARC',options=>dbms_logmnr.new);
- PL/SQL 过程已获胜告终。
- SQL> exec sys.dbms_logmnr.start_logmnr(options=>sys.dbms_logmnr.dict_from_online_catalog);
- PL/SQL 过程已获胜告终。
- OK,分析告终。
察看日志登记的内容
- SQL> select t.scn,t.timestamp,t.seg_owner,t.operation
- 2 from v$logmnr_contents t where t.seg_name='MYTESTTAB';
- SCN TIMESTAMP SEG_OWNE OPERATION
- ---------- -------------- -------- ----------
- 5483840 11-8月 -07 SYS DDL
- 5483863 11-8月 -07 SYS INSERT
- 5483874 11-8月 -07 SYS INSERT
- 5483885 11-8月 -07 SYS DELETE
- 5483885 11-8月 -07 SYS DELETE
- 5483885 11-8月 -07 SYS DELETE
- 5483885 11-8月 -07 SYS DELETE
- 5483886 11-8月 -07 SYS DELETE
- 5483886 11-8月 -07 SYS DELETE
- 已抉择9行。
- SQL> select t.SQL_REDO from v$logmnr_contents t where t.seg_name='MYTESTTAB';
- SQL_REDO
- ----------------------------------------------------------------------------------------------------
- create table mytesttab as select * from scott.dept;
- insert into "SYS"."MYTESTTAB"("DEPTNO","DNAME","LOC") values ('80','IT','WA');
- insert into "SYS"."MYTESTTAB"("DEPTNO","DNAME","LOC") values ('90','MGR','YR');
- delete from "SYS"."MYTESTTAB" where "DEPTNO" = '10' and "DNAME" = 'ACCOUNTING' and "LOC" = 'NEW
- YORK
- delete from "SYS"."MYTESTTAB" where "DEPTNO" = '20' and "DNAME" = 'RESEARCH' and "LOC" = 'DALLAS' an
- delete from "SYS"."MYTESTTAB" where "DEPTNO" = '30' and "DNAME" = 'SALES' and "LOC" = 'CHICAGO' and
- delete from "SYS"."MYTESTTAB" where "DEPTNO" = '40' and "DNAME" = 'OPERATIONS' and "LOC" = 'BOSTON'
- delete from "SYS"."MYTESTTAB" where "DEPTNO" = '80' and "DNAME" = 'IT' and "LOC" = 'WA' and ROWID =
- delete from "SYS"."MYTESTTAB" where "DEPTNO" = '90' and "DNAME" = 'MGR' and "LOC" = 'YR' and ROWID =
- 已抉择9行。
- SQL> select t.SQL_UNDO from v$logmnr_contents t where t.seg_name='MYTESTTAB';
- SQL_UNDO
- ----------------------------------------------------------------------------------------------------
- delete from "SYS"."MYTESTTAB" where "DEPTNO" = '80' and "DNAME" = 'IT' and "LOC" = 'WA' and ROWID =
- delete from "SYS"."MYTESTTAB" where "DEPTNO" = '90' and "DNAME" = 'MGR' and "LOC" = 'YR' and ROWID =
- insert into "SYS"."MYTESTTAB"("DEPTNO","DNAME","LOC") values ('10','ACCOUNTING','NEW YORK');
- insert into "SYS"."MYTESTTAB"("DEPTNO","DNAME","LOC") values ('20','RESEARCH','DALLAS');
- insert into "SYS"."MYTESTTAB"("DEPTNO","DNAME","LOC") values ('30','SALES','CHICAGO');
- insert into "SYS"."MYTESTTAB"("DEPTNO","DNAME","LOC") values ('40','OPERATIONS','BOSTON');
- insert into "SYS"."MYTESTTAB"("DEPTNO","DNAME","LOC") values ('80','IT','WA');
- insert into "SYS"."MYTESTTAB"("DEPTNO","DNAME","LOC") values ('90','MGR','YR');
- 已抉择9行。
关于Oracle 10g中的Logmnr的使用实例的介绍就到这里了,希望本次的介绍能够对您有所收获!