CREATE REPLICATION

Creates a new synchronous table replication for a table.

SYNTAX

replication_name Name of the synchronous table replicaton you want to create.
local_table_name Name of the local table you want to replicate.
column_name 1. Name of a column in the local table you want to replicate.
2. Name of a column in the remote table you want to replicate to.
search_condition Conditions a row must meet to be replicated.
remote_table_name Name of the table in the remote database you want to replicate to.

DESCRIPTION

The CREATE REPLICATION command creates a new synchronous table replication for a table. You cannot create a replication on a temporary table, a synonym, or a view. To execute the CREATE REPLICATION command on a table you must be the table owner, or have DBA or SYSADM security privileges.

A table replication creates a full or partial copy of a table in a remote location. This allows users in remote locations to work with a local copy of data. The local copy remains synchronized with the databases in other locations. This way each database can service data requests immediately and efficiently, without having to go to another machine over a slower network connection. This is not the same as backing up the database to a remote location, since the synchronization is done on a transaction-by-transaction basis by the DBMS itself, without any intervention from users.

There are two primary types of table replication: synchronous and asynchronous. Synchronous table replication modifies the remote table at the same time it modifies the local table, while asynchronous table replication stores changes to the local table and modifies the remote table based on a schedule. The CREATE REPLICATE command creates a synchronous table replication.

Synchronous table replication in DBMaker uses a global transaction model, in which the replication of data to the remote table is treated as an integral part of the local transaction. (A transaction is traditionally defined as a logical unit of work, or one or more operations on a database that must be completed together to leave the database in a consistent state. Transactions are self-contained an must either complete and change the data, or fail and leave the data unchanged.) This means that if the replication of data to the remote database fails, the transaction on the local table will also fail.

When you modify a synchronous table replication you must specify the replication name, the local table name, and the names of the additional remote tables you want to replicate to. Both the local table and the remote tables must already exist in their respective databases. DBMaker will automatically drop any replications you create on a table when you drop the table.

DBMaker will replicate the entire table unless you specify the individual columns you want to replicate using a column list. When you replicate an entire table without providing a column list, the columns in the local table and corresponding columns in the remote table must have the same name and data type. If the column names in the local and remote tables are different, you can provide a column list for the remote table. Columns in the local table (from left to right) will replicate to the corresponding columns named in the column list for the remote table. You can explicitly specify which columns in the local table correspond to columns in the remote table by providing a column list for both the local and remote tables. In all cases, you must include the primary key columns in the replication, and the number and data type of primary key columns in both tables must match.

Unlike most database objects, DBMaker does not identify replications using fully qualified names (a combination of owner and object names), but associates them with tables instead. For this reason all replication names on the same table must be unique. The replication operates with the same security and object privileges as the owner of the trigger table, unless the remote table is specified using links. In this case, the replication operates with the same security and object privileges as the link.

The WHERE keyword is optional. This keyword specifies the search condition to uses when replicating data to a remote table. DBMaker will only replicate rows that satisfy the search condition. See the WHERE clause in the description of the SELECT command for more information.

The CLEAR DATA/FLUSH DATA/CLEAR AND FLUSH DATA keywords are optional. These keywords specify the operations that will take place when you create a replication. The CLEAR DATA keywords will delete all data from the remote table when you create the replication. The FLUSH DATA keywords will copy all data that matches a search condition into the remote table. The CLEAR AND FLUSH DATA keywords will clear all data from the remote table, and then copy all data that matches a search condition into the remote table. If you do not specify an action, no action will take place.

Replication names have a maximum length of eighteen characters, and may contain numbers, letters, the underscore character, and the symbols $ and #. The first character may not be a number.

EXAMPLES

The following example creates a replication named EmpRep for the local table named Employees. The remote database is identified by a database configuration section named FieldOffice in the local dmconfig.ini configuration file. The remote table is also named Employees, and all column names and data types in both tables are the same.

CREATE REPLICATION EmpRep WITH PRIMARY AS Employees
REPLICATE TO FieldOffice:Employees

The following example is similar to the above example, but all data in the remote table is deleted and then any existing data in the local table is sent to the remote table.

CREATE REPLICATION EmpRep WITH PRIMARY AS Employees
REPLICATE TO FieldOffice:Employees
CLEAR AND FLUSH DATA

RELATED COMMANDS

< CREATE LINK | Contents | CREATE SYNONYM >

Copyright 2002 SYSCOM Computer Engineering Co. All rights reserved.