溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Oracle在線重定義之DBMS_REDEFINITION

發布時間:2020-08-10 22:34:01 來源:ITPUB博客 閱讀:246 作者:迷倪小魏 欄目:關系型數據庫

11g官方文檔關于DBMS_REDEFINITION的詳細說明:

******************************************************************************************************

Using DBMS_REDEFINITION

·         Overview

·         Constants

·         Operational Notes



Overview

To achieve online redefinition, incrementally maintainable local materialized views are used. These logs keep track of the changes to the master tables and are used by the materialized views during refresh synchronization.

為了實現在線重新定義,使用使用本地物化視圖。 這些日志將跟蹤主表的更改,并在刷新同步期間由物化視圖使用。



Constants

The DBMS_REDEFINITION package uses the constants shown in Table 110-1, "DBMS_REDEFINITION Constants":

Table 110-1 DBMS_REDEFINITION Constants

Constant

Type

Value

Description

CONS_CONSTRAINT

PLS_INTEGER

3

Used to specify that dependent object type is a constraint

CONS_INDEX

PLS_INTEGER

2

Used to specify that dependent object type is a index

CONS_MVLOG

PLS_INTEGER

10

Used to (un)register a materialized view log, as a dependent object of the table, through theREGISTER_DEPENDENT_OBJECT Procedureand theUNREGISTER_DEPENDENT_OBJECT Procedure.

CONS_ORIG_PARAMS

PLS_INTEGER

1

Used to specify that indexes should be cloned with their original storage parameters

CONS_TRIGGER

PLS_INTEGER

4

Used to specify that dependent object type is a trigger

CONS_USE_PK

BINARY_INTEGER

1

Used to indicate that the redefinition should be done using primary keys or pseudo-primary keys (unique keys with all component columns having not-NULL constraints)

CONS_USE_ROWID

BINARY_INTEGER

2

Used to indicate that the redefinition should be done using rowids

 

Operational Notes

·        CONS_USE_PK and CONS_USE_ROWID are constants used as input to the "options_flag" parameter in both the START_REDEF_TABLE Procedure andCAN_REDEF_TABLE Procedure. CONS_USE_ROWID is used to indicate that the redefinition should be done using rowids while CONS_USE_PK implies that the redefinition should be done using primary keys or pseudo-primary keys (which are unique keys with all component columns having NOT NULL constraints).

CONS_USE_PKCONS_USE_ROWID是用作START_REDEF_TABLE過程和CAN_REDEF_TABLE過程中“options_flag”參數的輸入的常量。 CONS_USE_ROWID用于指示重新定義應使用rowid完成,而CONS_USE_PK意味著重新定義應該使用主鍵或偽主鍵(這是所有組件列具有NOT NULL約束的唯一鍵)來完成。

·        CONS_INDEX, CONS_MVLOG,CONS_TRIGGER and CONS_CONSTRAINT are used to specify the type of the dependent object being (un)registered inREGISTER_DEPENDENT_OBJECT Procedure and UNREGISTER_DEPENDENT_OBJECT Procedure (parameter "dep_type").

CONS_INDEX,CONS_MVLOG,CONS_TRIGGERCONS_CONSTRAINT用于指定在REGISTER_DEPENDENT_OBJECT過程和UNREGISTER_DEPENDENT_OBJECT過程(參數“dep_type”)中注冊的依賴對象的類型。

CONS_INDEX ==> dependent object is of type INDEX

CONS_TRIGGER ==> dependent object is of type TRIGGER

CONS_CONSTRAINT==> dependent object type is of type CONSTRAINT

CONS_MVLOG ==> dependent object is of type MATERIALIZED VIEW LOG

·        CONS_ORIG_PARAMS as used as input to the "copy_indexes" parameter in COPY_TABLE_DEPENDENTS Procedure. Using this parameter implies that the indexes on the original table be copied onto the interim table using the same storage parameters as that of the original index.

作為COPY_TABLE_DEPENDENTS過程中“copy_indexes”參數的輸入的CONS_ORIG_PARAMS。 使用此參數意味著使用與原始索引相同的存儲參數將原始表上的索引復制到臨時表上。


Rules and Limits

For information about various rules and limits that apply to implementation of this package, see the Oracle Database Administrator's Guide.



Summary of DBMS_REDEFINITION Subprograms

Table 110-2 DBMS_REDEFINITION Package Subprograms

Subprogram

Description

ABORT_REDEF_TABLE Procedure

Cleans up errors that occur during the redefinition process and removes all temporary objects created by the reorganization process

CAN_REDEF_TABLE Procedure

Determines if a given table can be redefined online

COPY_TABLE_DEPENDENTS Procedure

Copies the dependent objects of the original table onto the interim table

FINISH_REDEF_TABLE Procedure

Completes the redefinition process.

REGISTER_DEPENDENT_OBJECT Procedure

Registers a dependent object (index, trigger, constraint or materialized view log) on the table being redefined and the corresponding dependent object on the interim table

START_REDEF_TABLE Procedure

Initiates the redefinition process

SYNC_INTERIM_TABLE Procedure

Keeps the interim table synchronized with the original table

UNREGISTER_DEPENDENT_OBJECT Procedure

Unregisters a dependent object (index, trigger, constraint or materialized view log) on the table being redefined and the corresponding dependent object on the interim table

 



ABORT_REDEF_TABLE Procedure

This procedure cleans up errors that occur during the redefinition process. This procedure can also be used to terminate the redefinition process any time after the START_REDEF_TABLE Procedure has been called and before the FINISH_REDEF_TABLE Procedure is called. This process will remove the temporary objects that are created by the redefinition process such as materialized view logs.

此過程可以清除在重新定義過程中發生的錯誤。 此過程也可以在START_REDEF_TABLE程序被調用之后和調用FINISH_REDEF_TABLE過程之前的任何時候用于終止重新定義過程。 此過程將刪除由重定義過程創建的臨時對象,例如物化視圖日志。

Syntax

DBMS_REDEFINITION.ABORT_REDEF_TABLE (
   uname       IN VARCHAR2,
   orig_table  IN VARCHAR2,
   int_table   IN VARCHAR2,
  part_name    IN  VARCHAR2 := NULL);

Parameters

Table 110-3 ABORT_REDEF_TABLE Procedure Parameters

Parameter

Description

uname

Schema name of the tables

orig_table

Name of the table to be redefined

int_table

Name of the interim table

part_name

Name of the partition being redefined. If redefining only a single partition of a table, specify the partition name in this parameter. NULL implies the entire table is being redefined.

 



CAN_REDEF_TABLE Procedure

This procedure determines if a given table can be redefined online. This is the first step of the online redefinition process. If the table is not a candidate for online redefinition, an error message is raised.

此過程確定給定的表是否可以在線重新定義。 這是在線重新定義過程的第一步。 如果表不是在線重新定義的候選者,則會出現錯誤消息。

Syntax

DBMS_REDEFINITION.CAN_REDEF_TABLE (
   uname         IN  VARCHAR2,
   tname        IN  VARCHAR2,
   options_flag  IN  PLS_INTEGER := 1,
   part_name     IN  VARCHAR2 := NULL);

Parameters

Table 110-4 CAN_REDEF_TABLE Procedure Parameters

Parameter

Description

uname

Schema name of the table

tname

Name of the table to be re-organized

options_flag

Indicates the type of redefinition method to use.

·         If dbms_redefinition.cons_use_pk, the redefinition is done using primary keys or pseudo-primary keys (unique keys with all component columns having NOT NULL constraints). The default method of redefinition is using primary keys.

·         If dbms_redefinition.cons_use_rowid, the redefinition is done using rowids.

part_name

Name of the partition being redefined. If redefining only a single partition of a table, specify the partition name in this parameter. NULL implies the entire table is being redefined.

 

Exceptions

If the table is not a candidate for online redefinition, an error message is raised.



COPY_TABLE_DEPENDENTS Procedure

This procedure clones the dependent objects of the table being redefined onto the interim table and registers the dependent objects. This procedure does not clone the already registered dependent objects.

This subprogram is used to clone the dependent objects like grants, triggers, constraints and privileges from the table being redefined to the interim table (which represents the post-redefinition table).

此過程克隆表重新定義到臨時表上的依賴對象,并注冊依賴對象。 此過程不會克隆已注冊的從屬對象。

 

該子程序用于將重新定義的表中的依賴對象(如授權,觸發器,約束和權限)克隆到臨時表(表示后重新定義表)。

Syntax

DBMS_REDEFINITION.COPY_TABLE_DEPENDENTS(
   uname                    IN  VARCHAR2,
   orig_table               IN  VARCHAR2,
   int_table                IN  VARCHAR2,
   copy_indexes             IN  PLS_INTEGER := 1,
   copy_triggers            IN  BOOLEAN     := TRUE,
   copy_constraints         IN  BOOLEAN     := TRUE,
   copy_privileges          IN  BOOLEAN     := TRUE,
   ignore_errors            IN  BOOLEAN     := FALSE,
   num_errors               OUT PLS_INTEGER,
   copy_statistics          IN  BOOLEAN     := FALSE, 
   copy_mvlog               IN  BOOLEAN     := FALSE); 

Parameters

Table 110-5 COPY_TABLE_DEPENDENTS Procedure Parameters

Parameter

Description

uname

Schema name of the tables

orig_table

Name of the table being redefined

int_table

Name of the interim table

copy_indexes

Flag indicating whether to copy the indexes

·         0 - do not copy any index

·         dbms_redefinition.cons_orig_params – copy the indexes using the physical parameters of the source indexes

copy_triggers

TRUE = clone triggers, FALSE = do nothing

copy_constraints

TRUE = clone constraints, FALSE = do nothing. If compatibility setting is 10.2 or higher, then clone CHECK andNOT NULL constraints

copy_privileges

TRUE = clone privileges, FALSE = do nothing

ignore_errors

TRUE = if an error occurs while cloning a particular dependent object, then skip that object and continue cloning other dependent objects. FALSE = that the cloning process should stop upon encountering an error.

num_errors

Number of errors that occurred while cloning dependent objects

copy_statistics

TRUE = copy statistics, FALSE = do nothing

copy_mvlog

TRUE = copy materialized view log, FALSE = do nothing

 

Usage Notes

·         The user must check the column num_errors before proceeding to ensure that no errors occurred during the cloning of the objects.

·         In case of an error, the user should fix the cause of the error and call the COPY_TABLE_DEPENDENTS Procedure again to clone the dependent object. Alternatively the user can manually clone the dependent object and then register the manually cloned dependent object using theREGISTER_DEPENDENT_OBJECT Procedure.

·         All cloned referential constraints involving the interim tables will be created disabled (they will be automatically enabled after the redefinition) and all triggers on interim tables will not fire till the redefinition is completed. After the redefinition is complete, the cloned objects will be renamed to the corresponding pre-redefinition names of the objects (from which they were cloned from).

·         It is the user's responsibility that the cloned dependent objects are unaffected by the redefinition. All the triggers will be cloned and it is the user's responsibility that the cloned triggers are unaffected by the redefinition.

?用戶必須先檢查列num_errors,然后繼續確??寺ο笃陂g不會發生錯誤。

?如果發生錯誤,用戶應該修復錯誤的原因并再次調用COPY_TABLE_DEPENDENTS過程來克隆依賴對象?;蛘?,用戶可以手動克隆依賴對象,然后使用REGISTER_DEPENDENT_OBJECT過程注冊手動克隆的依賴對象。

?涉及臨時表的所有克隆參照約束將被禁用(重定義后將自動啟用),并且臨時表上的所有觸發器都不會觸發,直到重新定義完成。重新定義完成后,克隆的對象將被重命名為對象的重新定義名稱(從中克隆到它們)。

?用戶有責任克隆的依賴對象不受重新定義的影響。所有的觸發器將被克隆,用戶有責任克隆的觸發器不受重新定義的影響。



FINISH_REDEF_TABLE Procedure

This procedure completes the redefinition process. Before this step, you can create new indexes, triggers, grants, and constraints on the interim table. The referential constraints involving the interim table must be disabled. After completing this step, the original table is redefined with the attributes and data of the interim table. The original table is locked briefly during this procedure.

此過程完成重新定義過程。 在此步驟之前,您可以在臨時表上創建新的索引,觸發器,授予和約束。 必須禁用涉及臨時表的參照約束。 完成此步驟后,原始表格將重新定義為臨時表格的屬性和數據。 在此過程中,原始表被短暫鎖定。

Syntax

DBMS_REDEFINITION.FINISH_REDEF_TABLE (
   uname       IN VARCHAR2,
   orig_table  IN VARCHAR2,
   int_table   IN VARCHAR2,
   part_name   IN  VARCHAR2 := NULL);

Parameters

Table 110-6 FINISH_REDEF_TABLE Procedure Parameters

Parameters

Description

uname

Schema name of the tables

orig_table

Name of the table to be redefined

int_table

Name of the interim table

part_name

Name of the partition being redefined. If redefining only a single partition of a table, specify the partition name in this parameter. NULL implies the entire table is being redefined.

 



REGISTER_DEPENDENT_OBJECT Procedure

This procedure registers a dependent object (index, trigger, constraint or materialized view log) on the table being redefined and the corresponding dependent object on the interim table.

此過程在重新定義的表上注冊依賴對象(索引,觸發器,約束或物化視圖日志),并在臨時表上注冊相應的依賴對象。

This can be used to have the same object on each table but with different attributes. For example: for an index, the storage and tablespace attributes could be different but the columns indexed remain the same

這可以用于在每個表上具有相同的對象,但具有不同的屬性。 例如:對于索引,存儲和表空間屬性可能不同,但索引的列保持不變

Syntax

DBMS_REDEFINITION.REGISTER_DEPEPENDENT_OBJECT(
   uname             IN VARCHAR2,
   orig_table        IN VARCHAR2,
   int_table         IN VARCHAR2,
   dep_type          IN  PLS_INTEGER,
   dep_owner         IN VARCHAR2,
   dep_orig_name     IN VARCHAR2,
   dep_int_name      IN  VARCHAR2);

Parameters

Table 110-7 REGISTER_DEPENDENT_OBJECT Procedure Parameters

Parameters

Description

uname

Schema name of the tables

orig_table

Name of the table to be redefined

int_table

Name of the interim table

dep_type

Type of the dependent object (see Constants and Operational Notes)

dep_owner

Owner of the dependent object

dep_orig_name

Name of the original dependent object

dep_int_name

Name of the interim dependent object

 

Usage Notes

·         Attempting to register an already registered object will raise an error.

·         Registering a dependent object will automatically remove that object from DBA_REDEFINITION_ERRORS if an entry exists for that object.

?嘗試注冊已注冊的對象會引發錯誤。

?如果該對象存在條目,則注冊依賴對象將自動從DBA_REDEFINITION_ERRORS中刪除該對象。



START_REDEF_TABLE Procedure

Prior to calling this procedure, you must manually create an empty interim table (in the same schema as the table to be redefined) with the desired attributes of the post-redefinition table, and then call this procedure to initiate the redefinition.

在調用此過程之前,你必須手動創建一個空的臨時表(與要重新定義的表相同的模式)與所需的后重新定義表的屬性,然后調用此過程來啟動重定義。

Syntax

DBMS_REDEFINITION.START_REDEF_TABLE (
   uname          IN VARCHAR2,
   orig_table     IN VARCHAR2,
   int_table      IN VARCHAR2,
   col_mapping    IN VARCHAR2 := NULL,
   options_flag   IN BINARY_INTEGER := 1,
   orderby_cols   IN VARCHAR2 := NULL,
   part_name     IN  VARCHAR2 := NULL);

Parameters

Table 110-8 START_REDEF_TABLE Procedure Parameters

Parameter

Description

uname

Schema name of the tables

orig_table

Name of the table to be redefined

int_table

Name of the interim table

col_mapping

Mapping information from the columns in the original table to the columns in the interim table. (This is similar to the column list on the SELECT clause of a query.) If NULL, all the columns in the original table are selected and have the same name after redefinition.

options_flag

Indicates the type of redefinition method to use:

·         If dbms_redefinition.cons_use_pk, the redefinition is done using primary keys or pseudo-primary keys (unique keys with all component columns having NOT NULL constraints). The default method of redefinition is using primary keys.

·         If dbms_redefinition.cons_use_rowid, the redefinition is done using rowids.

orderby_cols

This optional parameter accepts the list of columns (along with the optional keyword(s) ascending/descending) with which to order by the rows during the initial instantiation of the interim table (the order by is only done for the initial instantiation and not for subsequent synchronizations)

part_name

Name of the partition being redefined. If redefining only a single partition of a table, specify the partition name in this parameter. NULL implies the entire table is being redefined.

 



SYNC_INTERIM_TABLE Procedure

This procedure keeps the interim table synchronized with the original table.

此過程使臨時表與原始表同步。

Syntax

DBMS_REDEFINITION.SYNC_INTERIM_TABLE (
   uname          IN  VARCHAR2,
   orig_table     IN  VARCHAR2,
   int_table      IN  VARCHAR2,
   part_name      IN  VARCHAR2 := NULL);

Parameters

Table 110-9 SYNC_INTERIM_TABLE Procedure Parameters

Parameter

Description

uname

Schema name of the table

orig_table

Name of the table to be redefined

int_table

Name of the interim table

part_name

Name of the partition being redefined. If redefining only a single partition of a table, specify the partition name in this parameter. NULL implies the entire table is being redefined.

 

Usage Notes

·         This step is useful in minimizing the amount of synchronization needed to be done by the FINISH_REDEF_TABLE Procedure before completing the online redefinition.

·         This procedure can be called between long running operations (such as CREATE INDEX) on the interim table to sync it up with the data in the original table and speed up subsequent operations.

?在完成在線重新定義之前,此步驟對于最小化FINISH_REDEF_TABLE過程需要完成的同步量很有用。

?可以在臨時表上的長時間運行操作(如CREATE INDEX)之間調用此過程,以將其與原始表中的數據進行同步,并加快后續操作。




UNREGISTER_DEPENDENT_OBJECT Procedure

This procedure unregisters a dependent object (index, trigger, constraint or materialized view log) on the table being redefined and the corresponding dependent object on the interim table.

此過程在重新定義的表上取消注冊依賴對象(索引,觸發器,約束或物化視圖日志),并在臨時表上注銷相應的依賴對象。

Syntax

DBMS_REDEFINITION.UNREGISTER_DEPEPENDENT_OBJECT(
   uname              IN VARCHAR2,
   orig_table        IN VARCHAR2,
   int_table         IN VARCHAR2,
   dep_type          IN PLS_INTEGER,
   dep_owner         IN VARCHAR2,
   dep_orig_name     IN VARCHAR2,
   dep_int_name      IN  VARCHAR2);

Parameters

Table 110-10 UNREGISTER_DEPENDENT_OBJECT Procedure Parameters

Parameters

Description

uname

Schema name of the tables

orig_table

Name of the table to be redefined

int_table

Name of the interim table

dep_type

Type of the dependent object

dep_owner

Owner of the dependent object

dep_orig_name

Name of the original dependent object

dep_int_name

Name of the interim dependent object




作者:SEian.G(苦練七十二變,笑對八十一難)


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女