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”.
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”.
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.
In Adaptive Server, use create table to create the table, or use sp_help to verify that the table exists.
If you are replicating data from a source other than Adaptive Server, create the table according to the instructions for your database software. Other data server steps in this procedure may vary for heterogeneous replication.
If your database supports stored procedures, you can execute rs_send_repserver_cmd in the primary database to create one or more replication definitions for the table from which you want to copy data. Otherwise, in the primary Replication Server, create one or more replication definitions. 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”.
If you are using publications, execute the following steps at the primary Replication Server.
Create one or more publications for the tables you want to replicate using create publication.
Create one or more articles, replication definition extensions, for each replication definition you want to include in the publication using create article. You can include a where clause to specify a subset of rows to send to the destination database.
Validate the publications, using validate publication, so that you can create subscriptions against them.
See “Using publications” for more information about creating publications.
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.
For non-Adaptive Server primaries, see your Replication Agent documentation for instructions on marking tables and columns.
See “Marking tables for replication” for details.
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.
For non-Adaptive Server primaries, see your Replication Agent documentation for instructions.
See “Replicating text, unitext, image, and rawobject columns” for details.
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.
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.
The 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.
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.
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.
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.
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.
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.