Oracle7 Server Distributed Systems Volume II: Replicated Data

Contents Index Home Previous Next

Creating a Replicated Object

Only objects in a replicated object group can be replicated to another site. To add an object to a replicated object group, call the procedure CREATE_MASTER_REPOBJECT in the DBMS_REPCAT package. As shown in the following example, this object need not already exist:

DBMS_REPCAT.CREATE_MASTER_REPOBJECT(
    sname              => 'acct_rec', 
    oname              => 'emp', 
    type               => 'table', 
    use_existing_object => TRUE, 
    ddl_text           => 'CREATE TABLE acct_rec.emp AS . . .', 
    comment            => 'created by . . .',
    retry              => FALSE,
    copy_rows          => TRUE,
    gname              => 'acct');

This example adds the EMP table to the replicated object group ACCT. The comment is added to the RepObject view. The types of objects that you can replicate are: tables, views, indexes, synonyms, triggers, procedures, functions, packages, and package bodies.

Note: If a table has a foreign key constraint that references columns in the table, you may need to precreate and populate the table at the new master site.

Attention: Note that the symmetric replication facility does not support replication of clustered tables.

To avoid name conflicts, the name of the replicated table should not exceed 27 bytes in length.

You must call this procedure at the master definition site. Assuming that you have no other master sites yet, the object is created at the master definition site, if it does not already exist, using the DDL that you provided.

If you pass a SQL statement as the DDL text, it must not include a trailing semicolon. If you supply a PL/SQL package, package body, function, or procedure, it must include the trailing semicolon.

Before calling this procedure the replicated object group must be quiesced. If you are creating a new replicated object group, the system is automatically quiesced when you call CREATE_MASTER_REPGROUP; otherwise, you must call SUSPEND_MASTER_ACTIVITY.

You can also use this procedure to add an object to an existing replicated environment, which may include additional master sites. If your environment does include one or more additional master sites the object is asynchronously added to the replicated object group at those sites as described [*].

Replicating the Object at Each Master Site

When Oracle attempts to create the object at each master site, two parameters affect how the object is created: USE_EXISTING_OBJECT and COPY_ROWS. The default value for both of these parameters is TRUE.

If an object does not already exist at a master site, this procedure creates the object for you. For tables, you can choose to either populate the table with the data from the master definition site, or to populate the table yourself. If you choose to populate the table yourself, you are responsible for the consistency of the table at each master site.

If a table already exists at a master site, you can choose to

Oracle raises a duplicateobject exception if the table at the master site is not the same shape as the table at the master definition site. Shape of a table refers to the number of columns, the name of these columns, and the datatype of the columns. This exception is stored in the RepCatLog view.

If any non-table object already exists at a master site, Oracle raises a duplicateobject exception if the object at the master site does not have the same SQL definition as the object at the master definition site. This exception is stored in the RepCatLog view.

Precreating an object can be useful if you find it faster to copy the files yourself (for example, by exporting the tables of a quiesced master site and importing them into a potential master site), instead of having the replication facility copy them for you. If you do this, you should take great care to ensure that the contents of the objects at both sites are identical. You also need to ensure that no changes are replicated to that site until you have imported the data.

Table 4 - 1 displays the appropriate settings for these parameters.

Object Already Exists? COPY_ROWS USE_EXISTING_OBJECT Result
yes TRUE TRUE duplicateobject message if objects do not match. For tables, use data from master definition site.
yes FALSE TRUE duplicateobject message if objects do not match. For tables, Admin must ensure contents are identical.
yes TRUE/FALSE FALSE duplicateobject message
no TRUE TRUE/FALSE Object is created. Tables populated using data from master definition site.
no FALSE TRUE/FALSE Object is created. Admin must populate tables and ensure consistency of tables at all sites.
Table 4 - 1. Object Creation at Master Sites

Additional Information: The parameters for the CREATE_MASTER_REPOBJECT procedure are shown in Table 12 - 102, and the exceptions are listed in Table 12 - 103. See also the discussion of offline instantiation [*] and [*].


Contents Index Home Previous Next