Professional Documents
Culture Documents
Objectives
This lesson will introduce the new replication features for Oracle9i. The main features are quiesce
reduction, multi-tier materialized views, and fast refresh enhancements.
While it is true that the differences between materialized views used for summary management and
materialized views used for replication (formally known as snapshots) are becoming less distinct with
each release, there are still a few fundamental differences. In this lesson, we will focus only on
materialized views which are used for replication. Summary management abilities, such as aggregate
functions and query rewrite are not available, unless so noted.
SPECIFY_NEW_MASTERS
ADD_NEW_MASTERS
Export
RESUME_PROPAGATION_TO_MDEF
At MDEF
PREPARE_INSTANTIATED_MASTER
DBMS_REPCAT.SPECIFY_NEW_MASTERS
DBMS_REPCAT.SPECIFY_NEW_MASTERS ((
gname
gname IN
IN VARCHAR2,
VARCHAR2,
[master_list
[master_list IN
IN VARCHAR2
VARCHAR2 ||
master_table
master_table IN
IN DBMS_UTILITY.dblink_array]
DBMS_UTILITY.dblink_array]
);
);
DBMS_REPCAT.SPECIFY_NEW_MASTERS
DBMS_REPCAT.SPECIFY_NEW_MASTERS ((
gname
gname =>
=> 'HR_REP_GRP',
'HR_REP_GRP',
master_list
master_list =>
=> 'HR_GERMANY.ACME.COM,
'HR_GERMANY.ACME.COM,
HR_RUSSIA.ACME.COM');
HR_RUSSIA.ACME.COM');
DBMS_REPCAT Additions
SPECIFY_NEW_MASTERS is used to specify the master sites you intend to add to an existing
replication group. This routine is called on the master definitions site and replaces any masters in the
local DBA_REPSITES_NEW view for the given replication group with the list of masters specified.
In the example above, we are indicating that two new masters sites (HR_RUSSIA and
HR_GERMANY) are going to be added to the replication group HR_REP_GRP.
Arguments:
Note: This procedure is overloaded.
• GNAME - name of an existing replication group.
• MASTER_LIST - the set of masters that will be instantiated.
• MASTER_TABLE - the set of masters that will be instantiated. MASTER_TABLE must be 1-
based and dense. A terminating NULL is permitted, but not required.
Notes:
• If master_list is empty, all masters for the given replication group will be removed from the
DBA_REPSITES_NEW view.
• This procedure must be called at the master definition site for the given replication group.
EXTENSION_ID
EXTENSION_ID GOWNER
GOWNER
--------------------------------
-------------------------------- -------------------
-------------------
GNAME
GNAME DBLINK
DBLINK
--------------------
-------------------- -------------------------
-------------------------
FF MASTER_STATUS
MASTER_STATUS
-- ---------------
---------------
7E7961B3FE81625DE034080020CAFF6B
7E7961B3FE81625DE034080020CAFF6B PUBLIC
PUBLIC
HR_REP_GRP
HR_REP_GRP HR_GERMANY.ACME.COM
HR_GERMANY.ACME.COM
READY
READY
SEPCIFY_NEW_MASTERS
The output shown above resulted from having run the following command:
SQL> begin
2 dbms_repcat.specify_new_masters (
3 gname => 'HR_REP_GRP',
4 master_list => 'HR_GERMANY.acme.com');
5 end;
6 /
The replication group HR_REP_GRP maintains the READY status, so DML operations are still
allowed on the tables within this replication group.
DBMS_REPCAT.ADD_NEW_MASTERS
DBMS_REPCAT.ADD_NEW_MASTERS ((
export_required
export_required IN
IN BOOLEAN,
BOOLEAN,
[available_master_list
[available_master_list IN
IN VARCHAR2
VARCHAR2 ||
available_master_table
available_master_table IN
IN DBMS_UTILITY.dblink_array],
DBMS_UTILITY.dblink_array],
masterdef_consistent_at
masterdef_consistent_at OUT
OUT VARCHAR2,
VARCHAR2,
extension_id
extension_id OUT
OUT RAW,
RAW,
break_trans_to_masterdef
break_trans_to_masterdef IN
IN BOOLEAN
BOOLEAN :=
:= FALSE,
FALSE,
break_trans_to_new_masters
break_trans_to_new_masters IN
IN BOOLEAN
BOOLEAN :=
:= FALSE,
FALSE,
percentage_for_catchup_mdef
percentage_for_catchup_mdef IN
IN BINARY_INTEGER
BINARY_INTEGER :=
:= 100,
100,
cycle_seconds_mdef
cycle_seconds_mdef IN
IN BINARY_INTEGER
BINARY_INTEGER :=
:= 60,
60,
percentage_for_catchup_new
percentage_for_catchup_new IN
IN BINARY_INTEGER
BINARY_INTEGER :=
:= 100,
100,
cycle_seconds_new
cycle_seconds_new IN
IN BINARY_INTEGER
BINARY_INTEGER :=
:= 60);
60);
DBMS_REPCAT Additions
The ADD_NEW_MASTERS procedure adds the masters in the DBA_REPSITES_NEW view to the
master groups specified when the SPECIFY_NEW_MASTERSprocedure was run. All masters being
instantiated with table-level export must be accessible at this time. Masters instantiated by full
database export/import or change-based recovery need not be accessible. The return value is the
instantiation SCN that should be used for export or change-based recovery.
After running this procedure, do not disable or enable propagation of the deferred transaction queue
until after the new master sites have been added. The DBA_REPEXTENSIONS view must be empty
before you disable or enable propagation.
When you use either export/import or SCN-based recovery, propagation of deferred transactions to the
new master site is partially (for parallel propagation) or completely (for serial propagation) disabled
while the new master sites are being added. Therefore, make sure each existing master site has
enough free space to store the largest unpropagated deferred transaction queue that you may
encounter.
Arguments
NOTE: This procedure is overloaded.
• EXPORT_REQUIRED: set it to TRUE if and only if export is required.
• AVAILABLE_MASTER_LIST: a comma-separated list of masters to be instantiated using
table-level export/import.
Oracle9i Replication New Features AR1- 10
DBMS_REPCAT Additions (continued)
• AVAILABLE_MASTER_TABLE: list of masters to be instantiated using table-level
export/import. Do NOT specify masters which will be instantiated using full database export-
import or change-based recovery. A terminating NULL is permitted, but not required.
• MASTERDEF_CONSISTENT_AT: the instantiation SCN that should be used for export
(CONSISTENT_AT parameter) or change-based recovery (RECOVER DATABASE UNTIL
CHANGE).
• EXTENSION_ID: the identifier for the current pending add master database without quiesce
request.
• BREAK_TRANS_TO_MASTERDEF: [Optional] If TRUE and export_required is TRUE,
existing masters may continue to propagate their deferred RPC queues to the masterdef for
replication groups that are not adding master sites. Default value is FALSE.
• BREAK_TRANS_TO_NEW_MASTERS: [Optional] If TRUE, existing masters may continue to
propagate their deferred RPC queues to the new masters for replication groups that are not
adding master sites. Otherwise, propagation to the new masters will be disabled. Default value is
FALSE.
• PERCENTAGE_FOR_CATCHUP_MDEF: [Optional] Only used if EXPORT_REQUIRED and
BREAK_TRANS_TO_NEW_MASTERSare TRUE. The percentage of propagation resources
that should be used for catching up to masterdef. Must be a multiple of 10 between 0 and 100.
Default value is 100.
• CYCLE_SECONDS_MDEF: [Optional] Indicates the longest time propagation for the extended
replication groups to masterdef will be done before switching to the unaffected replication
group. This parameter is ignored if percentage_for_catchup_mdef is 100. Default value is 60.
• PERCENTAGE_FOR_CATCHUP_NEW: [Optional] Only used if BREAK_TRANS_TO_
NEW_MASTERS is TRUE.The percentage of propagation resources that should be used for
catching up to new masters. Must be a multiple of 10 between 0 and 100. Default value is 100.
• CYCLE_SECONDS_NEW: [Optional] indicates the longest time propagation for the extended
replication groups to new masters will be done before switching to the unaffected replication
group. This parameter is ignored if percentage_for_catchup_new is 100. Default value is 60.
Notes:
• For masters to be instantiated via change-based recovery or full database export/import, they
must include all replication groups in the master definition site.
• For table-level export-import, ensure that all the repcatlog requests in DBA_REPCATLOG view
for the extended groups have been processed without any error before import.
• This procedure must be called at the master definition site.
ADD_NEW_MASTERS Example
In this example, we specify the method to be used to instantiate the HR_GERMANY master site. We
have chosen to perform SCN-based recovery (export_required => FALSE), and to allow existing
masters to continue to propagate their deferred RPC queues to the new masters for replication groups
that are not adding master sites.
The bind variable masterdef_consistent_at, declared in SQL*Plus, allows you to display
the return variable after the procedure has executed by using the following command:
SQL> PRINT masterdef_consistent_at;
You can also view these values by querying the data dictionary views DBA_REPSITES_NEW and
DBA_REPEXTENSIONS:
SQL> SELECT CONSISTENT_AT FROM DBA_REPEXTENSIONS;
CONSISTENT_AT
-------------
3456871
DBMS_REPCAT.RESUME_PROPAGATION_TO_MDEF
DBMS_REPCAT.RESUME_PROPAGATION_TO_MDEF ((
extension_id
extension_id IN
IN RAW
RAW
);
);
DBMS_REPCAT.RESUME_PROPAGATION_TO_MDEF (
extension_id => '75AFDBD77CD83C4EE034080020CAFF6B');
EXTENSION_ID DBLINK
MASTER_STATUS
-------------------------------- ----------
-----------
75AFDBD77CD83C4EE034080020CAFF6B REP3.WORLD READY
DBMS_REPCAT.PREPARE_INSTANTIATED_MASTER
DBMS_REPCAT.PREPARE_INSTANTIATED_MASTER ((
extension_id
extension_id IN
IN RAW,
RAW,
new_global_name
new_global_name ININ VARCHAR2
VARCHAR2 :=
:= NULL
NULL
);
);
DBMS_REPCAT.PREPARE_INSTANTIATED_MASTER (
extension_id => :ext_id,
new_global_name => 'HR.MYCOM.DE');
ADD_NEW_MASTERS restrictions:
• Synchronous replication is not supported.
• Master definition site cannot be relocated for
any replication group being extended.
• Connection qualifier for all master group
database links must be the same.
• Parallel propagation is fully supported.
Serial propagation is only supported when
queue propagation is completely disabled
• All master sites must be using Oracle9i release
DBMS_REPCAT.UNDO_ADD_NEW_MASTERS_REQUEST
DBMS_REPCAT.UNDO_ADD_NEW_MASTERS_REQUEST ((
extension_id
extension_id IN
IN RAW,
RAW,
drop_contents
drop_contents IN
IN BOOLEAN
BOOLEAN :=
:= TRUE
TRUE );
);
block_row_dump:
block_row_dump:
tab
tab 0,
0, row
row 0,
0, @0x1f5c
@0x1f5c
tl:
tl: 44
44 fb:
fb: --H-FL--
--H-FL-- lb:
lb: 0x0
0x0 cc:
cc: 88
dscn
dscn 0x0000.00014866
0x0000.00014866
col
col 0:0: [[ 3]
3] c2
c2 4a
4a 46
46
col
col 1:1: [[ 5]
5] 53
53 4d
4d 49
49 54
54 48
48
col
col 2:2: [[ 5]
5] 43
43 4c
4c 45
45 52
52 4b
4b
Constraint SCNs
A constraint SCN is the SCN that is larger than the commit times of all the transactions that a
particular row operation depends on due to constraints. Constraints may be one of uniqueness or
referential integrity. For example, if there is a unique index on a table, a successful row insertion is
dependent on all the previously committed transactions that deleted the given unique key. The
constraint SCN captures this dependency.
Referential integrity (foreign key) constraint dependencies are of two kinds:
• Existence dependency on the parent: Inserting a row into a child table depends on the existence
of the foreign key in the parent table.
• Non-existence dependency on the child table: Deleting a row from a parent table depends on
the absence of rows with the foreign key in the child table.
The constraint SCN captures both of these forms of foreign key dependencies.
In Oracle8i, a dependency SCN was computed using the last committed transaction in a block.
Dependent SCN (DSCN) can result in the tracking of false dependencies. For example, the insertion
of a single key into an index block is made to depend on all other transactions that commit in the same
block. This includes the insertion of other keys. For rightmost or leftmost growing indexes, this can
lead to the tracking of false dependencies.
After a delete and insert into this leaf block, the LDSCN (0x0000.002317e) remains lower than the cleanout
SCN (0x0000.00023206).
To learn more about interpreting index leaf block dumps, see WebIV Note 33190.1 "QREF: Blockdump - Index
Block **INTERNAL ONLY**".
Oracle9i Replication New Features AR1- 22
New MV Fast Refresh Abilities
PROCEDURE
PROCEDURE explain_
explain_mview
mview ((
mv
mv IN
IN VARCHAR2,
VARCHAR2,
stmt_id
stmt_id IN
IN VARCHAR2
VARCHAR2 :=
:= NULL
NULL );
);
PROCEDURE
PROCEDURE explain_
explain_mview
mview ((
mv
mv IN
IN VARCHAR2,
VARCHAR2,
msg_array
msg_array IN
IN OUT
OUT ExplainMVArrayType
ExplainMVArrayType);
);
M
M Table
Table MLOG$_M
0 AA 2
15 Update:
Update: AA :=
:= 38
38
15 38
38
USLOG$_MV1
MV1
MV1 MView
MView
AA MLOG$_MV1
1
deftran 15
15
1 1 USLOG$_MV2
MV2
MV2 MView
MView
2 U:
U: A:=10
A:=10
AA Trigger Update:
Update: AA :=
:= 10
10
15
15 10
10
deftran Update: A := 10
M
M Table
Table MLOG$_M
0 AA
38 Update:
Update: AA :=
:= 38
38
38
USLOG$_MV1
2 MV1
MV1 MView
MView
2 Update:
U:
U: A:=10
A:=10 Update: AA :=
:= 10
10
AA MLOG$_MV1
1
deftran 15
15 10
10 Update:
Update: AA :=
:= 10
10
2
Conflict Res.
1 3
First refresh USLOG$_MV2
MV2
MV2 MView
MView 3
2 U:
U: A:=10
A:=10
AA Update:
Update: AA :=
:= 10
10
10
10
deftran
M
M Table
Table MLOG$_M
0 AA
38 Update:
Update: AA :=
:= 38
38
38 1
Push U:A:=10 1
Conflict Res. 1
USLOG$_MV1
U:
U: A:=10
A:=10
MV1
MV1 MView
MView 1 Update:
Update: AA :=
:= 10
10
AA MLOG$_MV1
1
deftran 10
10 38
38 Update:
Update: AA :=
:= 38
38
2
MV2
MV2 MView
MView USLOG$_MV2
2 AA
10
10
deftran
M
M Table
Table MLOG$_M
0 AA
38
38
USLOG$_MV1
MV1
MV1 MView
MView
AA MLOG$_MV1
1
deftran 38
38 Update:
Update: AA :=
:= 38
38
Second refresh
MV2
MV2 MView
MView USLOG$_MV2
2 AA
10
10 38
38
deftran
• V$REPLQUEUE
Instance-wide statistics for deferred transaction
queue
• V$REPLPROP
– Session-level view of parallel propagation status
– Rebuilt for each session or query
Usage:
Contains information on the replication transactions queued or purged since instance
startup.
Questions answered by this view:
• What is the average number of calls (row changes) in my replication transaction
since instance startup?
SELECT calls_enqueued/txns_enqueued FROM V$REPLQUEUE;
VIEW V$REPLPROP (
SID NUMBER,
SERIAL# NUMBER,
NAME VARCHAR2(71),
DBLINK VARCHAR2(129),
STATE VARCHAR2(12),
XID VARCHAR2(22),
SEQUENCE
Oracle9i Replication New Features AR1-
NUMBER );
43
Usage:
Gives the state of the coordinator and slave for currently ongoing parallel propagation
New Dynamic Views for Replication
V$MVREFRESH
• Visible only on the materialized view site
• Lists information on local materialized views
DESCRIBE
DESCRIBE VIEW
VIEW V$MVREFRESH;
V$MVREFRESH;
Name
Name Null?
Null? Type
Type
--------------------
-------------------- --------
-------- --------------------
--------------------
SID
SID NUMBER
NUMBER
SERIAL#
SERIAL# NUMBER
NUMBER
CURRMVOWNER
CURRMVOWNER VARCHAR2(31)
VARCHAR2(31)
CURRMVNAME
CURRMVNAME VARCHAR2(31)
VARCHAR2(31)
Usage:
Contains information on the materialized view currently being refreshed. Does not contain
information for updatable materialized views in the ‘push’phase (check V$REPLPROP instead).
Use this view to answer questions such as:
• What materialized view in the database is currently being refreshed?
SELECT * FROM V$MVREFRESH;
DBMS_DEFER_SYS.CLEAR_PROP_STATISTICS
DBMS_DEFER_SYS.CLEAR_PROP_STATISTICS ((
DBLINK
DBLINK IN
IN VARCHAR2
VARCHAR2 );
);
EXECUTE DBMS_DEFER_SYS.CLEAR_PROP_STATISTICS ( -
'REG1.ACME.COM');
DBMS_DEFER_SYS.CLEAR_PROP_STATISTICS
This procedure clears all the statistics (all columns after CATCHUP) from DEFSCHEDULE
for a specified database link.
Arguments:
• DBLINK - The destination whose statistics in DEFSCHEDULE are to be cleared.
The "ALTER TABLE MODIFY LONG … LOB" command works like the "ALTER TABLE MOVE"
command . Hence the contents of the table are copied into a new space, and the old space is removed at
the end of the operation. This temporarily doubles the space requirements. But the advantage is that
after the transformation , the table will not have any embedded NULLs in place of the old LONG
column, so the performance of subsequent DMLs / queries on the table will not deteriorate.
Objectives
This lesson will introduce the new replication features: replication of objects.
Note:
In this lesson, we will focus only on materialized views which are used for replicating data between
two databases. These features do not apply to materialized views used for data warehousing or
summary management unless so indicated.
BEGIN
DBMS_REPCAT.CREATE_MASTER_REPOBJECT (
gname => 'OBJ_REP', type => 'TYPE',
sname => 'OE', oname => 'CUST_ADDRESS_TYP');
END;
BEGIN
DBMS_REPCAT.CREATE_MASTER_REPOBJECT (
gname => 'OBJ_REP', type => 'TABLE',
sname => 'OE', oname => 'CUST');
END;
BEGIN
DBMS_RECTIFIER_DIFF.DIFFERENCES (
sname1 => 'OE',
oname1 => 'CUST',
reference_site => 'HQ.ACME.COM',
sname2 => 'OE',
oname2 => 'CUST',
comparison_site => 'REG1.ACME.COM',
column_list => 'customer_id, cust_address',
missing_rows_sname => 'repadmin',
missing_rows_oname1 => 'missing_rows_data',
missing_rows_oname2 => 'missing_rows_location',
missing_rows_site => 'hq.acme.com',
commit_rows => 50);
END;
/