DBMS_REPCAT.CREATE_SNAPSHOT_REPOBJECT( sname => 'accts_rec', oname => 'emp', type => 'snapshot', ddl_text => 'CREATE SNAPSHOT accts_rec.emp FOR UPDATE AS SELECT * FROM emp@acct_hq.hq.com WHERE deptno > 500', comment => 'created on ...', gname => 'acct') gen_obj_owner ==> 'REPADMIN';
In this example, Oracle creates a snapshot at the snapshot site of the EMP table located at the master site. This snapshot contains a subset of the rows in the EMP table; that is, it only contains the rows for those employees whose department numbers are larger than 500. For example, this might be all sales staff in the western region.
Attention: Notice that the object name and updatable snapshot name must be identical. The master table must be a replicated object registered at the master site.
In this example, the SQL statement necessary to create the snapshot is passed as an argument to this procedure. Alternatively, you could have created the snapshot before calling this procedure and simply have omitted the DDL.
Warning: If you create an updatable snapshot using the FOR UPDATE clause of the CREATE SNAPSHOT command, but do not create the snapshot as a replicated object by calling CREATE_SNAPSHOT_REPOBJECT, any changes that you make to the updatable snapshot will be lost when you refresh the snapshot.
In addition to creating the snapshot as a replicated object at the snapshot site, Oracle also adds the object name and type to the RepObject view at the local site. This view is used to determine which objects need to push their changes to the master site.
Because the replicated object in this example is of type SNAPSHOT and its associated master table uses row-level replication, Oracle installs the appropriate replication support at the snapshot site. For snapshots of tables using procedural replication, be sure to replicate the associated procedure or package at the snapshot site.
Attention: Although not required, you will typically want all snapshots at a given snapshot site to be in the same snapshot refresh group. To ensure that snapshots in the same refresh group are refreshed consistently, their associated master tables must be located at the same master site.
Additional Information: The parameters for the CREATE_SNAPSHOT_REPOBJECT procedure are shown in Table 12 - 107, and the exceptions are listed in Table 12 - 108.
Updatable snapshots are created and deleted in the same manner as read-only snapshots. See Chapter 3. To create an updatable snapshot, simply add the FOR UPDATE clause to the CREATE SNAPSHOT statement as shown in the following example:
CREATE SNAPSHOT emp FOR UPDATE AS SELECT * FROM scott.emp@sales.ny.com;
Snapshots of LONG columns are not supported.
Updatable snapshots must be simple snapshots; that is each row in the snapshot is based on a single row in a single remote table. A simple snapshot's defining query has no distinct or aggregate functions, GROUP BY or CONNECT BY clauses, subqueries, joins, or set operations.
Symmetric replication does not support replication of a subset of columns. All CREATE statements must be of the form
CREATE SNAPSHOT . . . FOR UPDATE AS SELECT * FROM . . .;
The following SQL statement is not supported:
CREATE SNAPSHOT . . . FOR UPDATE AS SELECT empno, ename FROM . . .;