Supplemental Logging分为两种:Database-Level Supplemental Logging和table-Level Supplemental Logging,即数据库级别和表级别。下面我们来看看Oracle官方文档对其的介绍和说明,引自 http://docs.oracle.com/cd/E11882_01/server.112/e22490/logminer.htm#SUTIL1582
一、Database-Level Supplemental Logging
There are two types of database-level supplemental logging: minimal supplemental logging and IDentification key logging.Minimal supplemental logging does not impose significant overhead on the database generating the redo log files. However,enabling database-wIDe IDentification key logging can impose overhead on the database generating the redo log files.
--数据库级别的补充日志包括两种:minimal supplement logging和IDentification key logging。Minimal supplemental logging不会强加太多的信息到redo log;IDentification key logging会强加大量的信息到redo log。
1. Minimal Supplemental Logging
Minimal supplemental logging logs the minimal amount of information needed for Logminer to IDentify,group,and merge the redo operations associated with DML changes. It ensures that Logminer (and any product building on Logminer technology) has sufficIEnt information to support chained rows and varIoUs storage arrangements,such as cluster tables and index-organized tables. To enable minimal supplemental logging,execute the following sql statement:
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
2. Database-Level IDentification Key Logging
IDentification key logging is necessary when redo log files will not be mined at the source database instance,for example,when the redo log files will be mined at a logical standby database.
Using database IDentification key logging,you can enable database-wIDe before-image logging for all updates by specifying one or more of the following options to the sql ALTER DATABASE ADD SUPPLEMENTAL LOG statement:
2.1 ALL system-generated unconditional supplemental log group
This option specifIEs that when a row is updated,all columns of that row (except for LOBs,LONGS,and ADTs) are placed in the redo log file.
To enable all column logging at the database level,execute the following statement:
sql> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (ALL) ColUMNS;
--对于ALL ColUMNS补充日志来说,当行被修改时,该行的所有列都会被记录到日志文件中
2.2 PRIMARY KEY system-generated unconditional supplemental log group
This option causes the database to place all columns of a row's primary key in the redo log file whenever a row containing a primary key is updated (even if no value in the primary key has changed).
If a table does not have a primary key,but has one or more non-null unique index key constraints or index keys,then one of the unique index keys is chosen for logging as a means of uniquely IDentifying the row being updated.
If the table has neither a primary key nor a non-null unique index key,then all columns except LONG and LOB are supplementally logged; this is equivalent to specifying ALL supplemental logging for that row. Therefore,Oracle recommends that when you use database-level primary key supplemental logging,all or most tables be defined to have primary or unique index keys.
sql> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY) ColUMNS;
--对于PRIMARY KYE ColUMNS补充日志来说,当行被修改时,该行的主键将被记录到日志文件中,无论该行的主键是否被修改。如果该表没有主键,但有一个或多个非空唯一键,则任意一个非空主键将被记录到日志文件中,如果该表既没有主键,也没有非空唯一键,则该行的所有列将被记录到日志文件中。
2.3 UNIQUE system-generated conditional supplemental log group
This option causes the database to place all columns of a row's composite unique key or bitmap index in the redo log file if any column belonging to the composite unique key or bitmap index is modifIEd. The unique key can be due to either a unique constraint or a unique index.
sql> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (UNIQUE) ColUMNS;
--对于UNIQUE ColUMNS补充日志来说,当行被修改时,该行的唯一键或bitmap index将被记录到日志文件中。
2.4 FOREIGN KEY system-generated conditional supplemental log group
This option causes the database to place all columns of a row's foreign key in the redo log file if any column belonging to the foreign key is modifIEd.
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (FOREIGN KEY) ColUMNS;
注意:
1. When you enable IDentification key logging at the database level,minimal supplemental logging is enabled implicitly.
2. Supplemental logging statements are cumulative. If you issue the following sql statements,then both primary key and unique key supplemental logging is enabled:
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY) ColUMNS;ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (UNIQUE) ColUMNS;
3. DropPing minimal supplemental log data is allowed only if no other variant of database-level supplemental logging is enabled.
--如果启动了IDentification key logging,则minimal supplemental logging将隐性启动;补充日志是叠加的;只有当所有IDentification key logging被禁止以后,minimal 补充日志才会被禁止。
禁止命令如下:
ALTER DATABASE DROP SUPPLEMENTAL LOG DATA (PRIMARY KEY) ColUMNS;ALTER DATABASE DROP SUPPLEMENTAL LOG DATA;
二、 table-Level Supplemental Logging
table-level supplemental logging specifIEs,at the table level,which columns are to be supplementally logged. You can use IDentification key logging or user-defined conditional and unconditional supplemental log groups to log supplemental information,as described in the following sections.
1. table-Level IDentification Key Logging --针对所有列的
IDentification key logging at the table level offers the same options as those provIDed at the database level: all, primary key,foreign key,and unique key. However,when you specify IDentification key logging at the table level,only the specifIEd table is affected.
-- Database-Level IDentification Key Logging与table-Level Supplemental Logging的区别,前者是针对全库的,后者是针对表的。表级别的补充日志也是叠加的。
2. table-Level user-defined Supplemental Log Groups --针对某些列的
In addition to table-level IDentification key logging,Oracle supports user-defined supplemental log groups. With user-defined supplemental log groups,you can specify which columns are supplementally logged. You can specify conditional or unconditional log groups,as follows:
2.1 user-defined unconditional log groups
To enable supplemental logging that uses user-defined unconditional log groups,use the ALWAYS
clause as shown in the following example:
ALTER table HR.EMPLOYEES ADD SUPPLEMENTAL LOG GROUP emp_parttime (EMPLOYEE_ID,LAST_name,DEPARTMENT_ID) ALWAYS;
This creates a log group named emp_parttime
on the hr.employees
table that consists of the columns employee_ID
, last_name
,and department_ID
. These columns will be logged every time an UPDATE
statement is executed on the hr.employees
table,regardless of whether the update affected these columns.
--对于user-defined unconditional log groups,只要行被修改,无论列组中的列是否被修改,该组中的列都会被记录到日志文件中。
2.2 user-defined conditional supplemental log groups
To enable supplemental logging that uses user-defined conditional log groups,omit the ALWAYS
clause from the sql ALTER
table
statement,as shown in the following example:
ALTER table HR.EMPLOYEES ADD SUPPLEMENTAL LOG GROUP emp_fulltime (EMPLOYEE_ID,DEPARTMENT_ID);
This creates a log group named emp_fulltime
on table hr.employees
. Just like the prevIoUs example,it consists of the columns employee_ID
,and department_ID
. But because the ALWAYS
clause was omitted,before-images of the columns will be logged only if at least one of the columns is updated.
--相比unconditional log groups,conditional supplemental log groups语句中只是少了关键字ALWAYS,只有该列组中的列被修改时,该组中列的信息才会记录到日志文件中。
2.3 user-defined supplemental log groups with NO LOG
For both unconditional and conditional user-defined supplemental log groups,you can explicitly specify that a column in the log group be excluded from supplemental logging by specifying the NO
LOG
option. When you specify a log group and use the NO
LOG
option,you must specify at least one column in the log group without the NO
LOG
option,as shown in the following example:
ALTER table HR.EMPLOYEES ADD SUPPLEMENTAL LOG GROUP emp_parttime( DEPARTMENT_ID NO LOG,EMPLOYEE_ID);
This enables you to associate this column with other columns in the named supplemental log group such that any modification to the NO
LOG
column causes the other columns in the supplemental log group to be placed in the redo log file. This might be useful,if you want to log certain columns in a group if a LONG
column changes. You cannot supplementally log the LONG
column itself; however,you can use changes to that column to trigger supplemental logging of other columns in the same row.
--譬如:新建一个表,其中,带有LONG字段,sql> create table test(ID number,ename long);
构建包括ename在内的supplemental log groups
sql> alter table scott.test add supplemental log group test_g(loc,ID) always;
alter table scott.test add supplemental log group test_g(loc,ID) always
*
ERROR at line 1:
ORA-30569: data type of given column is not supported in a log group
可见,在log group中,long类型不支持。
在此,我们可以对long类型的列指定为NO LOG。如下所示:
sql> alter table scott.test add supplemental log group test_g(ename no log,ID) always;
table altered.
总结
以上是内存溢出为你收集整理的Supplemental Logging全部内容,希望文章能够帮你解决Supplemental Logging所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)