Define a unique key
Note: Valid for Oracle tables only.
If a table was not created with a primary or unique key, you can specify columns to use as a key when you specify the object in the configuration file. SharePlex uses the specified columns as a unique key in its WHERE clause to locate target rows for posting.
NoteS:
- Without a primary or unique key, SharePlex uses all of the columns of a table (or all of the columns in a column partition) as a key, which slows replication performance.
- When a key definition is specified for a table that has a PRIMARY or UNIQUE key, the key definition overrides the defined key. This can be useful if you do not want any of the existing keys to be used by SharePlex.
The columns that you specify as a key must meet the following criteria:
- They cannot be LONG or LOB columns.
- They must be able to uniquely identify a row. Otherwise, replication could return out-of-sync errors or post to incorrect target rows.
- They must be part of the column partition if the table is configured for vertically partitioned replication. When using the exclude column notation in vertical partitioning, the excluded columns cannot be used in the key definition. For more information, see Configure partitioned replication.
- Include the columns in a supplemental log group. Otherwise, SharePlex must query the database for their values.
- Create an index on the target table and add the index to the SharePlex hints file, located in the variable-data directory, which directs the Post process to use the index.
Syntax for key definition
To create a key definition, type a space after the source object and use the following syntax, including the parentheses.
src_owner.table !key (column_list)
where:
- !key is a required keyword.
- column_list is a list of columns to include in the key. Separate column names with commas. A space after the comma is optional.
datasource_specification |
|
|
src_owner.table !key (col_name, col2_name, ...) |
tgt_owner.table |
host@o.SID |
Example
Datasource:o.ora1
scott.tab !key(name,ID) scott.tab2 sysB@oraB