group In this example, we create a snapshot refresh group of read−only snapshots: DECLARE vSnapshotList dbms_utility.uncl_array BEGIN vSnapshotList1 = 'COUNTRIES' vSnapshotList2 = 'STA
Trang 1(Oracle8 only)
Used only if parallelism > 0 Sets the maximum number of transactions to be examined simultaneously for determining parallel scheduling Oracle determines this value internally; you are advised not to use it
The MAKE procedure does not raise any exceptions
14.2.2.1.1 Examples
The following examples illustrate how the MAKE procedure may be used
14.2.2.1.2 Read−only snapshot group
In this example, we create a snapshot refresh group of read−only snapshots:
DECLARE
vSnapshotList dbms_utility.uncl_array
BEGIN
vSnapshotList(1) = 'COUNTRIES'
vSnapshotList(2) = 'STATES'
vSnapshotList(3) = 'POSTAL_CODES'
vSnapshotList(4) = 'CUSTOMER_ADDRESSES'
DBMS_REFRESH.MAKE(name => 'SG_ADDR_TABS',
tab => vSnapShotList,
next_date => TRUNC(sysdate) + 1,
interval => 'SYSDATE + 1');
END;
This example shows the simplest invocation of DBMS_REFRESH.MAKE; defaults are used for all possible parameters This call creates a snapshot group on four related tables, and schedules them to be refreshed at every day at midnight
14.2.2.1.3 Read−only snapshot group with specialized parameters
In the following example, we create a snapshot refresh group of read−only snapshots with specialized
parameters:
DECLARE
vSnapshotList dbms_utility.uncl_array
BEGIN
vSnapshotList(1) = 'COUNTRIES'
vSnapshotList(2) = 'STATES'
vSnapshotList(3) = 'POSTAL_CODES'
vSnapshotList(4) = 'CUSTOMER_ADDRESSES'
DBMS_REFRESH.MAKE(name => 'SG_ADDR_TABS',
tab => vSnapShotList,
next_date => TRUNC(sysdate) + 1,
interval => 'SYSDATE + 1',
implicit_destroy => TRUE,
lax => TRUE,
rollback_segment 'RB1');
END;
This example creates the same snapshot group as in the previous example, but with some additional
properties:
implicit_destroy = TRUE
This setting causes the snapshot group SG_ADDR_TABS to be destroyed if all of the snapshots in the group are dropped The default behavior is to preserve the snapshot group, even if it has no members
14.2.2 Creating and Destroying Snapshot Groups 621
Trang 2lax = TRUE
If any of the snapshots being added to SG_ADDR_TABS exist in another snapshot group, this setting instructs Oracle to remove them from the other group before adding them to the new group A
snapshot cannot be a member of more than one snapshot group
rollback_segment = `RB1'
This setting causes Oracle to use rollback segment RB1 whenever it refreshes snapshot group
SG_ADDR_TABS You should consider specifying rollback segments if your snapshot refreshes result in long transactions requiring a large rollback segment
14.2.2.1.4 Parallel propagation
In the next example, we create a snapshot refresh group that uses parallel propagation (Oracle8 only):
DECLARE
vSnapshotList dbms_utility.uncl_array
BEGIN
vSnapshotList(1) = 'COUNTRIES'
vSnapshotList(2) = 'STATES'
vSnapshotList(3) = 'POSTAL_CODES'
vSnapshotList(4) = 'CUSTOMER_ADDRESSES'
DBMS_REFRESH.MAKE(name => 'SG_ADDR_TABS',
tab => vSnapShotList,
next_date => TRUNC(sysdate) + 1,
interval => 'SYSDATE + 1',
parallelism => 4,);
END;
This example sets parallelism to 4, so that Oracle uses four processes to perform the refresh
14.2.2.2 The DBMS_REFRESH.DESTROY procedure
Call the DESTROY procedure to destroy a snapshot group For both Oracle7 and Oracle8, you call
DESTROY as follows,
PROCEDURE DBMS_REFRESH.DESTROY (name IN VARCHAR2);
where name is the name of the snapshot group to be destroyed
The DESTROY procedure raises the following exception:
Name Number Description
ORA−23404 −23404 Refresh group name does not exist
14.2.2.2.1 Example
This example destroys the snapshot group SG_ADDR_TABS:
BEGIN
DBMS_REFRESH.DESTROY( name => 'SG_ADDR_TABS' );
END;
This example does not drop the member snapshots themselves; however, they will not be refreshed again unless you either add them to another snapshot group, or refresh them manually with the
DBMS_SNAPSHOT.REFRESH procedure
14.2.2 Creating and Destroying Snapshot Groups 622
Trang 314.2.3 Adding and Subtracting Snapshots from Snapshot Groups
With the ADD and SUBTRACT procedures, you can add and subtract the snapshots in a snapshot group after you have created the group As with the other DBMS_REFRESH procedures, you must call these procedures from the snapshot site
NOTE: A snapshot group cannot have more than 100 members.
14.2.3.1 The DBMS_REFRESH.ADD procedure
Call the ADD procedure to add a snapshot group The specification follows:
PROCEDURE DBMS_REFRESH.ADD
(name IN VARCHAR2,
{list IN VARCHAR2,| tab IN dbms_utility.uncl_array,}
lax IN BOOLEAN DEFAULT FALSE );
The parameters for the ADD procedure have the same meaning as in the MAKE procedure; refer to the parameter table in that section Note that you must select the list or tab parameter, but not both
The ADD procedure does not raise any exceptions
14.2.3.1.1 Example
This example uses the ADD procedure to add the snapshots PROVINCES and CONTINENTS to the existing snapshot group SG_ARR_TABS:
BEGIN
DBMS_REFRESH.ADD
(name => 'SG_ADDR_TABS', list => 'PROVINCES', CONTINENTS');
END;
14.2.3.2 The DBMS_REFRESH.SUBTRACT procedure
Call the SUBTRACT procedure to subtract a snapshot group The specification follows:
PROCEDURE DBMS_REFRESH.SUBTRACT
(name IN VARCHAR2,
{list IN VARCHAR2,| tab IN dbms_utility.uncl_array,}
lax IN BOOLEAN DEFAULT FALSE );
The parameters for the SUBTRACT procedure have the same meaning as in the MAKE procedure; refer to the parameter table in that section Note that you must select the list or tab parameter, but not both
The SUBTRACT procedure does not raise any exceptions
14.2.3.2.1 Example
The following example removes the snapshots STATES and COUNTRIES from the existing snapshot group SG_ADDR_TABS Since we also specified lax = TRUE, the call also drops the snapshot group if there are no other member snapshots remaining
BEGIN
DBMS_REFRESH.SUBTRACT( name => 'SG_ADDR_TABS',
list => 'STATES', COUNTRIES',
lax => TRUE);
END;
14.2.3 Adding and Subtracting Snapshots from Snapshot Groups 623
Trang 414.2.4 Altering Properties of a Snapshot Group
The CHANGE procedure allows you to modify settings associated with a snapshot group You can change any of the parameters that are available in DBMS_REFRESH.MAKE:
interval
implicit_destroy
rollback_segment
push_deferred_rpc
refresh_after_errors
purge_option (Oracle8 only)
parallelism (Oracle8 only)
heap_size (Oracle8 only)
Refer to the MAKE section for an explanation of these parameters
14.2.4.1 The DBMS_REFRESH.CHANGE procedure
Call the CHANGE procedure to modify a snapshot group's setting The specifications for CHANGE differ for Oracle7 and Oracle8 as follows
Here is the Oracle7 specification:
PROCEDURE DBMS_REFRESH.CHANGE
(name IN VARCHAR2,
next_date IN DATE DEFAULT NULL,
interval IN VARCHAR2 DEFAULT NULL,
implicit_destroy IN BOOLEAN DEFAULT NULL,
rollback_seg IN VARCHAR2 DEFAULT NULL,
push_deferred_rpc IN BOOLEAN DEFAULT NULL,
refresh_after_errors IN BOOLEAN DEFAULT NULL);
Here is the Oracle8 specification:
PROCEDURE DBMS_REFRESH.CHANGE
(name IN VARCHAR2,
next_date IN DATE := NULL,
interval IN VARCHAR2 := NULL,
implicit_destroy IN BOOLEAN := NULL,
rollback_seg IN VARCHAR2 := NULL,
push_deferred_rpc IN BOOLEAN := NULL,
refresh_after_errors IN BOOLEAN := NULL,
purge_option IN BINARY_INTEGER := NULL,
parallelism IN BINARY_INTEGER := NULL,
heap_size IN BINARY_INTEGER := NULL);
As with the MAKE procedure, the difference between the Oracle7 and Oracle8 CHANGE specifications is the inclusion of support for parallel propagation and purging in the Oracle8 version
The CHANGE procedure does not raise any exceptions
14.2.5 Manually Refreshing Snapshot Groups
The REFRESH procedure refreshes a snapshot group
14.2.4 Altering Properties of a Snapshot Group 624
Trang 514.2.5.1 The DBMS_REFRESH.REFRESH procedure
Call REFRESH to refresh a snapshot group A call to REFRESH causes all members of snapshot group name
to be refreshed with the settings that you have designated in DBMS_REFRESH.MAKE and/or
DBMS_REFRESH.CHANGE The specification is,
PROCEDURE DBMS_REFRESH.REFRESH (name IN VARCHAR2);
where name identifies the snapshot group
The REFRESH procedure does not raise any exceptions
14.1 DBMS_SNAPSHOT:
Managing Snapshots
14.3 DBMS_OFFLINE_SNAPSHOT:
Performing Offline Snapshot
Instantiation
Copyright (c) 2000 O'Reilly & Associates All rights reserved.
14.2.5 Manually Refreshing Snapshot Groups 625