cdr define template

The cdr define template command creates a template for replicates and a replicate set.

Because templates define replicates, many of the syntax options for the cdr define template command are the same as for the cdr define replicate command.

Syntax


1  cdr define template template?  %Connect Option  (1)  %Conflict Options  (2)?  %Scope Options  (3)?  %Special Options  (4)   --master=server_group?   --exclusive  --database=database
2.1 +  table
2.1   --all
2.1  --file=filename
Element Purpose Restrictions Syntax
template Name of the template to create. The template name must be unique and cannot be the same as a replicate or replicate set name. Long Identifiers
database Name of the database that is used to define the template attributes. The database server must be registered with Enterprise Replication. Long Identifiers
table Name of the table to be included in the template. The table must be an actual table. It cannot be a synonym or a view. For ANSI databases, you must specify owner.tablename. Long Identifiers
filename The directory and file name of the file that contains a list of tables to be included in the template. Must be a full path name and file name. The path and file name can be no longer than 256 bytes. Within the file, the table names can be separated by a space or placed on different lines. Follows naming conventions on your operating system.
server_group Name of a database server group to declare for Enterprise Replication. Must be the name of an existing database server group in SQLHOSTS. Long Identifiers

The following table describes the options to cdr define template.

Long Form Short Form Meaning
--all -a Specifies that all tables in the database are included in the template.
--database= -d Specifies which database the template is based on. If no tables or table list file name are listed after this option, then all tables in the database are included in the template.
--exclusive -X Creates an exclusive replicate set. The state of the replicate set is inactive until you apply the template. This option is required if you have referential integrity constraints on a table.
--file= -f Specifies the path and file name of a file that lists the tables to be included in the template. The file must contain only table names, either separated by spaces or each on its own line.
--master= -M Specifies the server that contains the database to be used as the basis of the template. If this option is not specified, then the server that is specified in the connect option is used.

Special Options

Special Options

1+ 
1  --ats
1  --ris
1  --floatieee
1  --floatcanon
1  --firetrigger
1  --fullrow=
2.1! y
2.1 n
1  --ignoredel=
2.1 y
2.1! n
2.1  --anyUniqueKey
1  --UTF8=
2.1 y
2.1! n
1  --alwaysRepLOBs=
2.1 y
2.1! n

The following table describes the special options to the cdr define template command.

Long Form Short Form Meaning
--alwaysRepLOBS= Specifies whether columns that contain unchanged large objects are included in replicated rows:
  • --alwaysRepLOBS=n: Default. Columns that contain unchanged large objects are not replicated.
  • --alwaysRepLOBS=y: Columns that contain large objects are always included in replicated rows.
--anyUniqueKey -U Specifies that the replication key is detected automatically from the following sources in the follow order:
  • A primary key that is defined on the table
  • ERKEY shadow columns that are included in the table
  • Any unique key or unique constraint that is defined on the table

The replicate must be a strictly mastered replicate.

If the table includes ERKEY shadow columns, those columns are included in the participant definition only if the table does not have a primary key.

--ats -A Activates aborted transaction spooling for replicate transactions that fail to be applied to the target database.
--firetrigger -T Specifies that the rows that the replicate inserts fire triggers at the destination.
--floatieee -I Transfers replicated floating-point numbers in either 32-bit (for SMALLFLOAT) or 64-bit (for FLOAT) IEEE floating-point format. Use this option for all new replicate definitions.
--floatcanon -F Transfers replicated floating-point numbers in machine-independent decimal representation. This format is portable, but can lose accuracy. This format is provided for compatibility with earlier versions only; use --floatieee for all new replicate definitions.
--fullrow= -f

Specifies whether to replicate full rows or only the changed columns:

  • --fullrow=y = Default. Indicates to replicate the full row and to enable upserts. If you also specify deletewins as the conflict resolution rule, upserts are disabled.
  • --fullrow=n = Indicates to replicate only changed columns and disable upserts.
--ignoredel= -D Specifies whether to retain deleted rows on other nodes:
  • --ignoredel=y = Indicates that rows are retained if they are deleted on other nodes in the Enterprise Replication domain. You cannot use this option if you specify deletewins as the conflict resolution rule.
  • --ignoredel=n = Default. Indicates that deleted rows are deleted on all nodes in the Enterprise Replication domain.
--ris -R Activates row-information spooling for replicate row data that fails conflict resolution or encounters replication order problems.
--UTF8= None Specifies whether to enable conversion to and from UTF-8 (Unicode) when you replicate data between servers that use different code sets.
  • --UTF8=y Default. Indicates that character columns are converted to UTF-8 when the row is copied into the transmission queue. When the replicated row is applied on the target server, the data is converted from UTF-8 to the code set used on the target server. No attempt is made to convert character data that is contained within opaque data types. You cannot use --UTF8=y for replicates that contain TimeSeries data types, user-defined data types, or DataBlade® module data types.
  • -UTF8=n Indicates that code set conversion is ignored.

Usage

A template consists of schema information about a database, a group of tables, column attributes, and the replication keys that identify rows. A template defines a group of master replicates and a replicate set. Templates are an alternative to using the cdr define replicate and cdr start replicate commands for each table and manually combining the replicates into a replicate set by using the cdr define replicateset command.

The replicate set can be exclusive or non-exclusive. Specify that the replicate set is exclusive if you have referential constraints that are placed on the replicated columns. If you create an exclusive replicate set using a template, you do not stop the replicate set to add replicates. The cdr define template command performs this task automatically.

If your tables include the ERKEY shadow columns, they are automatically added to replicate definition when you define a template. The --erkey option is not needed with the cdr define template command.

You cannot specify an SPL routine for conflict resolution when you define a template.

After you define a template by running the cdr define template command, use the cdr realize template command to apply the template to your Enterprise Replication database servers.

You cannot update a template. To modify a template, you must delete it and then re-create it with the cdr define template command.

You can run this command from within an SQL statement by using the SQL administration API.

Examples

The following example illustrates the cdr define template command:
cdr define template tem1 -c detroit\
-C timestamp -S tran \
--master=chicago\
--database=new_cars table1 table2 table3
Line 1 of the example specifies a template name of tem1 and that the connection is made to the server detroit. Line 2 specifies a conflict-resolution rule of timestamp and a transaction scope for conflict resolution. Line 3 specifies that the master replicate information is obtained from the server chicago. Line 4 specifies to use the new_cars database on the chicago server and to include only the tables table1, table2, and table3.
The next example is the same as the first except that it has additional options and uses a file instead of a list of tables:
cdr define template tem1 -c detroit\
-C timestamp -S tran --master=chicago\
--ignoredel=y\
--database=new_cars --file=tabfile.txt
Line 3 indicates that delete operations are not replicated. Retaining deleted rows on target servers is useful for consolidation models.
Line 4 specifies a file name for a file that contains a list of tables to include in the template. The tabfile.txt file has the following contents:
table1
table2
table3
table4