日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Supplemental Logging

發布時間:2023/12/9 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Supplemental Logging 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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.EMPLOYEESADD 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.EMPLOYEESADD SUPPLEMENTAL LOG GROUP emp_fulltime (EMPLOYEE_ID, LAST_NAME, 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,?last_name, 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.EMPLOYEESADD 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, for example, 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.

? ?

轉載于:https://www.cnblogs.com/xieweikai/p/6838229.html

總結

以上是生活随笔為你收集整理的Supplemental Logging的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。