When you create a replication definition, you list the names and datatypes of the columns from the table that you want to copy.
A column’s name and datatype will be the same in the replicate table as in the primary table unless you specify a different replicate (published) column name or datatype.
Enclose the names of all of the columns and their datatypes in parentheses. For multiple columns, separate each column and its datatype from the next column with a comma.
For example, the following command creates a replication definition named publishers_rep1 for source and destination tables named publishers. It includes all the columns and their datatypes.
create replication definition publishers_rep1 with primary at TOKYO_DS.pubs2 with all tables named publishers (pub_id char(4), pub_name varchar(40), city varchar(20), state char(2)) primary key (pub_id)
The following command creates a replication definition named publishers_rep2 that omits the city column. Destination sites that do not require this column can subscribe to this replication definition.
create replication definition publishers_rep2 with primary at TOKYO_DS.pubs2 with all tables named publishers (pub_id char(4), pub_name varchar(40), state char(2)) primary key (pub_id)
Performance is best if columns are listed in the same order in the replication definition as in the tables themselves.
You can use only native and user defined datatypes supported by Replication Server. If a primary table has columns with user-defined datatypes, you must use a compatible supported datatype in the replication definition. You can also employ user-defined datatypes supplied with Replication Server as part of the installation process.
See “Datatypes” in Chapter 2, “Topics,” in the Replication Server Reference Manual for complete details on the datatypes supported by Replication Server.
When you want only one replication definition for a source table, and the source column names differ from their destination counterparts, use the column_name as replicate_column_name clause in the replication definition.
For example, for a source table named publishers1 and a destination table named publishers2, where the source column pub1_name corresponds to the destination column pub2_name, enter this:
create replication definition publishers_rep with primary at TOKYO_DS.pubs2 with primary table named publishers1 with replicate table named publishers2 (pub_id char(4), pub1_name as pub2_name varchar(40), city varchar(20), state char(2)) primary key (pub_id)
When you create multiple replication definitions for the same source table, the declared column datatype (the column datatype in the primary table) must be the same, except when the column’s datatype is rawobject or rawobject in row, which correspond respectively to the image and varbinary datatypes. Specifically you can:
Declare a column’s datatype as rawobject in one replication definition, but declare the same column’s datatype as image in another replication definition for the same table
Declare a column’s datatype as rawobject in row in one replication definition, but declare the same column’s datatype as varbinary in another replication definition for the same table
The replicate (published) column datatype can be different between replication definitions for the same table, with no restrictions.
When a column is listed in an existing replication definition for a primary table, specifying the column datatype is optional in subsequent replication definitions for the same primary table—the datatype is inherited from the previous replication definition and retained for the subsequent definition, even if the first definition (where you specified the datatype) is dropped.
To change a column datatype, use the alter replication definition command. Refer to “Altering column datatypes”.
The replicate table may include a column that is not in the replication definition if the column has a defined default value or you use a custom function string to apply a value to that column.Columns can be specified to accept null values in create table. When source rows are copied to the destination table, extra columns are filled with null values or may be updated separately by the local data server.
To copy text, unitext, image, or the Java datatypes rawobject and rawobject in row column data to any destination site, include those columns in the replication definition. Replicating text, unitext, image, or Java columns involves additional special procedures and considerations.
See “Replicating text, unitext, image, and rawobject columns” and “Java datatypes in Replication Server” for more information.
To distribute updates to particular sites, use the rs_address special datatype. See “Using the rs_address datatype” and “Bitmap subscriptions” for more information.
You can use the identity special datatype if the table you are copying contains an identity column. See “Replicating identity columns” for more information.
You can also use the timestamp special datatype if the table you are copying contains a timestamp column. See “Replicating timestamp columns” for more information.
To change the datatype of the replicated value at the primary database to a datatype acceptable to the replicate database, use the map to clause of the create replication definition command. See “Translating datatypes using HDS” for more information.