Copyright (c) 2000 O'Reilly & Associates. All rights reserved. [Appendix A] What's on the Companion Disk? 14.1.6 Registering Snapshots 616 Chapter 14 Snapshots 14.2 DBMS_REFRESH: Managing Snapshot Groups The DBMS_REFRESH package contains procedures for administrating snapshot groups. A snapshot group is a collection of one or more snapshots that Oracle refreshes in an atomic transaction, guaranteeing that relationships among the master tables are preserved in the snapshot tables. The DBMS_REFRESH package includes packages that perform the following functions: • Create and destroy snapshot groups • Add and subtract snapshots from snapshot groups • Manually refresh snapshot groups • Change properties of the snapshot group, such as the refresh interval Figure Figure 14.1 shows how DBMS_REFRESH works and Figure Figure 14.2 illustrates snapshot groups. Figure 14.1: DBMS_REFRESH components 617 Figure 14.2: A snapshot group 14.2.1 Getting Started with DBMS_REFRESH The DBMS_REFRESH package is created when the Oracle database is installed. The dbmssnap.sql script (found in the built−in packages source directory, as described in Chapter 1) contains the source code for this package's specification. This script is called by catproc.sql, which is normally run immediately after database creation. The script creates the public synonym DBMS_REFRESH for the package and grants EXECUTE privilege on the package to public. All Oracle users can reference and make use of this package. [Appendix A] What's on the Companion Disk? 14.2 DBMS_REFRESH: Managing Snapshot Groups 618 Table 14−3 lists the programs available in the DBMS_REFRESH package. Table 14.3: DBMS_REFRESH Programs Name Description Use in SQL? ADD Adds one or more snapshots to an existing refresh group No CHANGE Changes parameters associated with a refresh group No DESTROY Removes a refresh group No MAKE Creates a refresh group No REFRESH Forces a refresh of a refresh group No SUBTRACT Removes one or more snapshots from a refresh group No DBMS_REFRESH does not define any exceptions. 14.2.2 Creating and Destroying Snapshot Groups The MAKE and DESTROY procedures create and destroy snapshot groups, respectively. You call these procedures from the snapshot site. 14.2.2.1 The DBMS_REFRESH.MAKE procedure Call the MAKE procedure to create a snapshot group. Note that you must select either the list or tab parameter, but not both. The specifications for Oracle7 and Oracle8 versions differ as follows. Here is the Oracle7 specification: PROCEDURE DBMS_REFRESH.MAKE (name IN VARCHAR2, {list IN VARCHAR2,| tab IN dbms_utility.uncl_array,} next_date IN DATE, interval IN VARCHAR2, implicit_destroy IN BOOLEAN DEFAULT FALSE, lax IN BOOLEAN DEFAULT FALSE, job IN BINARY_INTEGER DEFAULT 0, rollback_seg IN VARCHAR2 DEFAULT NULL, push_deferred_rpc IN BOOLEAN DEFAULT TRUE, refresh_after_errors IN BOOLEAN DEFAULT FALSE ); Here is the Oracle8 specification: PROCEDURE DBMS_REFRESH.MAKE (name IN VARCHAR2, {list IN VARCHAR2,| tab IN dmbs_utility.uncl_array,} next_date IN DATE, interval IN VARCHAR2, implicit_destroy IN BOOLEAN := FALSE, lax IN BOOLEAN := FALSE, job IN BINARY_INTEGER := 0, rollback_seg IN VARCHAR2 := NULL, push_deferred_rpc IN BOOLEAN := TRUE, refresh_after_errors IN BOOLEAN := FALSE, purge_option IN BINARY_INTEGER := 1, parallelism IN BINARY_INTEGER := 0, [Appendix A] What's on the Companion Disk? 14.2.2 Creating and Destroying Snapshot Groups 619 heap_size IN BINARY_INTEGER := 0); In both Oracle7 and Oracle8, the MAKE procedure is overloaded; you can supply the list of snapshots either as a comma−separated string with the list parameter, or as a PL/SQL table with the tab parameter. Parameters are summarized in the following table. Name Description name Name of the refresh group to create. list A comma−delimited string of snapshots to include in the new refresh group. Use either list or tab to specify the snapshot(s) you want to add. tab A PL/SQL table of snapshots to include in the new refresh group. Use either list or tab to specify the snapshot(s) you want to add. next_date The time of the next refresh. interval A DATE expression indicating the snapshot group's refresh interval. implicit_destroy If set to TRUE, the snapshot group is destroyed if all snapshots are removed from it. lax If set to TRUE and the snapshot(s) already exist in a refresh group other than name, the snapshot(s) are first removed from the other group. job Used by import utility. Always use default value of 0. rollback_seg Specifies the rollback segment to use during snapshot refreshes. If set to NULL, the default rollback segment is used. push_deferred_rpc For updateable snapshots only. Setting this parameter to TRUE indicates that local updates will be pushed back to the master site (otherwise, local updates will not be visible during the refresh). refresh_after_errors For updateable snapshots only. Setting this parameter to TRUE indicates that refreshes should occur even if errors exist in the DEFERROR data dictionary view. purge_option (Oracle8 only) If push_deferred_rpc is TRUE, this designates the purge method; default is 1. • 0 No purge • 1 Lazy purge (optimized for time) • 2 Aggressive purge (complete) parallelism (Oracle8 only) • If push_defered_rpc is TRUE, this determines the maximum degree of parallelism; default is 1. • 0 Serial • 1 Parallel with 1 slave • N Parallel with N slaves (N > 1) [Appendix A] What's on the Companion Disk? 14.2.2 Creating and Destroying Snapshot Groups 620 . either the list or tab parameter, but not both. The specifications for Oracle7 and Oracle8 versions differ as follows. Here is the Oracle7 specification: PROCEDURE DBMS_REFRESH.MAKE (name IN VARCHAR2, . with DBMS_REFRESH The DBMS_REFRESH package is created when the Oracle database is installed. The dbmssnap.sql script (found in the built−in packages source directory, as described in Chapter 1). Disk? 14.2.2 Creating and Destroying Snapshot Groups 619 heap_size IN BINARY_INTEGER := 0); In both Oracle7 and Oracle8 , the MAKE procedure is overloaded; you can supply the list of snapshots either as