PL/SQL Packages and Types Reference 10g Release 1 (10.1) Part Number B10802-01 |
|
|
View PDF |
The DBMS_REDEFINITION
package provides an interface to perform an online redefinition of tables.
See Also:
Oracle Database Administrator's Guide for more information. |
This chapter contains the following topics:
To achieve online redefinition, incrementally maintainable local materialized views are used. Materialized view logs need to be defined on the master tables to support incrementally maintainable materialized views. These logs keep track of the changes to the master tables and are used by the materialized views during refresh synchronization.
The following constants are defined for this package:
cons_orig_params constant PLS_INTEGER := 1;
cons_use_pk constant BINARY_INTEGER := 1;
cons_use_rowid constant BINARY_INTEGER := 2;
cons_index constant PLS_INTEGER := 2;
cons_constraint constant PLS_INTEGER := 3;
cons_trigger constant PLS_INTEGER := 4;
cons_use_pk
and cons_use_rowid
are constants used as input to the "options_flag" parameter in both the START_REDEF_TABLE Procedure and CAN_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_index
, cons_trigger
and cons_constraint
are used to specify the type of the dependent object being (un)registered in REGISTER_DEPENDENT_OBJECT Procedure and UNREGISTER_DEPENDENT_OBJECT Procedure (parameter "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_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.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 start_redef_table
has been called and before finish_redef_table
is called.
DBMS_REDEFINITION.ABORT_REDEF_TABLE ( uname IN VARCHAR2, orig_table IN VARCHAR2, int_table IN VARCHAR2);
Parameter | Description |
---|---|
|
The schema name of the tables. |
|
The name of the table to be redefined. |
|
The name of the interim table. |
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.
DBMS_REDEFINITION.CAN_REDEF_TABLE ( uname IN VARCHAR2, tname IN VARCHAR2, options_flag IN PLS_INTEGER := 1);
If the table is not a candidate for online redefinition, an error message is raised.
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 API will be used to clone the dependent objects like grants, triggers, constraints and privileges from the table being redefined onto the interim table (which represents the post-redefinition table).
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).
DBMS_REDEFINITION.COPY_TABLE_DEPENDENTS( uname IN VARCHAR2, orig_table IN VARCHAR2, int_table IN VARCHAR2, copy_indexes IN PLS_INTEGER := 0, 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);
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.
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.
DBMS_REDFINITION.FINISH_REDEF_TABLE ( uname IN VARCHAR2, orig_table IN VARCHAR2, int_table IN VARCHAR2);
Parameters | Description |
---|---|
|
The schema name of the tables. |
|
The name of the table to be redefined. |
|
The name of the interim table. |
This procedure registers a dependent object (index, trigger or constraint) on the table being redefined and the corresponding dependent object on the interim table.
DBMS_REDFINITION.REGISTER_DEPEPENDENT_OBJECT( uame 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);
DBA_REDEFINITION_ERRORS
if an entry exists for that object.After verifying that the table can be redefined online, you 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.
DBMS_REDINITION.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 );
This procedure keeps the interim table synchronized with the original table. This step is useful in minimizing the amount of synchronization needed to be done by finish_redef_table
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.
DBMS_REDFINITION.SYNC_INTERIM_TABLE ( uname IN VARCHAR2, orig_table IN VARCHAR2, int_table IN VARCHAR2);
Parameter | Description |
---|---|
|
The schema name of the table. |
|
The name of the table to be redefined. |
|
The name of the interim table. |
This procedure unregisters a dependent object (index, trigger or constraint) on the table being redefined and the corresponding dependent object on the interim table.
DBMS_REDFINITION.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);