标签:order use ati ice 归档 tor 用户 在线 a10
LogMiner两种使用类型,一种是使用源数据库的数据字典分析DML操作,别一种是摘取LogMiner数据字典到字典文件分析DDL操作。
检查下suppplemental logging:
SQL> SELECT SUPPLEMENTAL_LOG_DATA_MIN FROM V$DATABASE;
如果是YES 或者IMPLICIT则表明已经生效了,否则需要启动:
安装LogMiner
查看系统中是否存在运行LogMiner所需要的dbms_logmnr、dbms_logmnr_d包,如果没有需要安装LogMiner工具,必须首先要运行下面这样两个脚本:
SQL> SELECT distinct name,text,line FROM DBA_SOURCE where type = ‘PACKAGE‘ and name = upper( ‘dbms_logmnr_d‘);
SQL> @?$ORACLE_HOME/rdbms/admin/dbmslm.sql
SQL> @?$ORACLE_HOME/rdbms/admin/dbmslmd.sql.
-- 创建数据字典文件之前需要配置LogMiner文件夹:
SQL> select * from dba_directories;
SQL> CREATE DIRECTORY utlfile AS ‘D:\oracle\oradata\practice\LOGMNR‘;
SQL> alter system set utl_file_dir=‘D:\oracle\oradata\practice\LOGMNR‘ scope=spfile;
SQL> SHOW PARAMETER utl_file_dir
--创建字典文件需要以DBA用户登录,创建到上面配置好的LogMiner文件夹中:
SQL> CONN LOGMINER/ LOGMINER@PRACTICE AS SYSDBA
SQL> EXECUTE dbms_logmnr_d.build(dictionary_filename => ‘dictionary.ora‘, dictionary_location =>‘D:\oracle\oradata\practice\LOGMNR‘);
SQL>alter database add supplemental log data;
Database altered.
SQL> select supplemental_log_data_min,supplemental_log_data_pk,supplemental_log_data_ui from v$database;
SUPPLEME SUP SUP
-------- --- ---
YES NO NO
-- Oracle的LogMiner可以分析在线(online)和归档(offline)两种日志文件,加入分析日志文件使用dbms_logmnr.add_logfile过程,第一个文件使用dbms_logmnr.NEW参数,后面文件使用dbms_logmnr.ADDFILE参数
SQL> col member for a50;
SQL> select * from v$logfile;
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- -------------------------------------------------- ---
3 ONLINE /home/oracle/app/oradata/orcl/redo03.log NO
2 ONLINE /home/oracle/app/oradata/orcl/redo02.log NO
1 ONLINE /home/oracle/app/oradata/orcl/redo01.log NO
SQL> select group#,status from v$log;
GROUP# STATUS
---------- ----------------
1 INACTIVE
2 INACTIVE
3 CURRENT
SQL> select name from v$archived_log where name is not null order by 1;
no rows selected
SQL> EXECUTE DBMS_LOGMNR.ADD_LOGFILE(LogFileName=>‘/home/oracle/app/oradata/orcl/redo03.log‘,Options=>dbms_logmnr.new);
PL/SQL procedure successfully completed.
SQL>EXECUTE DBMS_LOGMNR.ADD_LOGFILE(LogFileName=>‘/home/oracle/app/oradata/orcl/redo03.log‘,Options=>dbms_logmnr.ADDFILE);
PL/SQL procedure successfully completed.
SQL> execute DBMS_LOGMNR.START_LOGMNR(options=>dbms_logmnr.dict_from_online_catalog);
PL/SQL procedure successfully completed.
SQL> col username for a10;
SQL> col sql_redo for a45;
SQL> select username,scn,timestamp,sql_redo from v$logmnr_contents where seg_name=‘ANDY‘ order by scn;
USERNAME SCN TIMESTAMP SQL_REDO
---------- ---------- --------- ---------------------------------------------
UNKNOWN 1301179 15-OCT-14 create table andy(id int);
UNKNOWN 1301259 15-OCT-14 insert into "ANDY"."ANDY"("ID") values (‘1‘);
ANDY 1301738 15-OCT-14 insert into "ANDY"."ANDY"("ID") values (‘2‘);
ANDY 1301743 15-OCT-14 insert into "ANDY"."ANDY"("ID") values (‘3‘);
ANDY 1301774 15-OCT-14 truncate table andy;
标签:order use ati ice 归档 tor 用户 在线 a10
原文地址:http://www.cnblogs.com/andy6/p/6067854.html