Replication procedure

The following procedure summarizes the steps required to replicate data using table replication definitions and subscriptions, and where to turn for detailed instructions. For an example of the entire process, see “Subscription example”.

  1. Be sure you understand the issues described in “Planning a replication system”. Verify that you prepared the replication system as described under “Preparing a replication system”.

  2. Create the table as the Database Owner in the primary database, if it does not already exist, or, if there is a different table owner, specify the table owner name when you create the replication definition.

  3. In the primary Replication Server, create one or more replication definitions for the table from which you want to copy data. Each replication definition can be subscribed to by a different site that uses a different table view.

    When you create replication definitions, anticipate the requirements for the subscribing table, as described in step 8. The replication definition may contain all or a subset of the columns in the source table. It may specify the same or different table names, owner names, column names, or datatypes for the source and destination tables. It may change the datatype of the replicated value.

    See “Using the create replication definition command” for details. See also “Creating multiple replication definitions per table”.

  4. If you are using publications, execute the following steps at the primary Replication Server.

    See “Using publications” for more information about creating publications.

  5. Mark the primary table for replication.

    In the primary Adaptive Server, use sp_setreptable to enable table replication. This step allows the RepAgent thread to forward transactions for the table to the primary Replication Server.

    NoteFor non-Adaptive Server primaries, see your Replication Agent documentation for instructions on marking tables and columns.

    See “Marking tables for replication” for details.

  6. If the primary table contains text, unitext, image, or rawobject columns, you may need to use sp_setrepcol in the primary Adaptive Server to adjust the replication status for these columns.

    NoteFor non-Adaptive Server primaries, see your Replication Agent documentation for instructions.

    See “Replicating text, unitext, image, and rawobject columns” for details.

  7. Prepare a login name for the user creating the subscription. Login names that create subscriptions at replicate Replication Servers must also exist at the primary Replication Server.

    See Chapter 8, “Managing Replication Server Security”

  8. In the replicate database, create a table that matches the schema published by the replication definition. Create the replicate table as the Database Owner or as the same table owner specified in the replication definition.

    In Adaptive Server, use create table to create the table, or use sp_help to verify that the table exists.

    The replicate table may have the same or different name and/or the same or different owner name as the primary table. It may contain all or a subset of the columns in the primary table, with the same or different column names or datatypes. The replication definition must specify any such differences between the primary and replicate tables.

    NoteThe replicate table may include a column that is not in the replication definition if the column accepts null values, has a defined default value, or you use a custom function string to apply a value to that column.

  9. Grant the replicate database maintenance user login name select, insert, delete, and update permissions on the replicate table. The maintenance user executes commands for replicated transactions.

    See Chapter 8, “Managing Replication Server Security”.

  10. If necessary, customize your database operations using functions, function strings, and function-string classes. Replication Server function strings execute data server operations.

    See Chapter 2, “Customizing Database Operations” in the Replication Server Administration Guide Volume 2 for details.

  11. Create a subscription in the replicate Replication Server. If you are using publications, proceed to step 12.

    Log in to a replicate Replication Server and create one or more subscriptions to the table replication definition for the data you want to copy. You can subscribe to all the rows in the replication definition’s columns, or use a where clause to copy only certain rows.

    A replicate database can subscribe to multiple replication definitions of a primary table, but a replicate table can subscribe to only one replication definition of a primary table.

    When you create a subscription, the replicate table is filled in with the initial table data in a process called materialization. In most cases, Replication Server copies data into the replicate table automatically. You can also manually materialize the data.

    See Chapter 11, “Managing Subscriptions” for more information about creating and materializing subscriptions.

  12. If you are using publications, create a publication subscription against the publications created in step 4. Execute create subscription at the replicate Replication Server.

    When you create a publication subscription, Replication Server creates subscriptions against each article in the publication. Article subscriptions do not contain where clauses.

    See “Using publication subscriptions” for more information about publication subscriptions.

  13. Check the subscription status.

    Verify that the subscription data has fully materialized in the replicate database and that transactions are replicating successfully.

    See Chapter 11, “Managing Subscriptions” for details.