Use Wildcards to Specify Multiple Tables for PostgreSQL
You can use wildcard characters to specify multiple tables of a schema in one entry of the configuration file. SharePlex replicates any tables that satisfy the wildcard, except those that you explicitly exclude.
Note: Only table names can be wildcarded. Schema names cannot be wildcarded.
Requirements and limitations of wildcard support
The schemas that contain wildcarded table names must exist on the source and target before the configuration is activated.
Supported wildcard syntax
SharePlex supports the following PostgreSQL wildcards:
- Percent (%) wildcard to specify a string. (See the Examples)
- Underscore (_) wildcard to specify a single-character.
- For table names that contain a percent sign or an underscore character (for example emp_salary), SharePlex recognizes the backslash (\) as an escape character to denote the character as a literal, not a wildcard.
Specify wildcarded names in the configuration file
Use this template for help when specifying a wildcarded name in the configuration file.
Configuration with wildcarded table names
datasource_specification |
expand src_schema.wildcard_name [not (list)] |
tgt_schema.wildcard_name |
routing_map |
Description of syntax elements
expand |
Indicates that the specification contains wildcard characters that must be expanded. When SharePlex detects the expand keyword, it queries the database for all tables that match the criteria in the wildcard specification. Without this required keyword, the wildcard characters are assumed to be part of an explicit table name, and no wildcard expansion is performed.
Note: Leave a space between expand and the start of the source table specification. |
src_schema.wildcard_name |
- src_schema is the schema of the source tables. Schema names cannot be wildcarded. If wildcards are used in the schema name, SharePlex assumes that they are part of the schema name.
- wildcard_name is the wildcarded name of the source tables.
PostgreSQL: The names of the target tables must be identical to those of the source tables, but the tables may belong to different schemas. |
not (list) |
An exclusion list that defines tables to omit from the wildcard expansion. Use this option to exclude tables that you do not want to be replicated. Note: This not keyword does not have the same meaning as the SQL wildcard NOT operator.
- The not keyword and parentheses are required elements.
- list is a comma-separated list of tables owned by the same schema, either wildcarded or explicit. Example: not (spo%, gen%, product).
Leave a space before and after the not keyword. A space is allowed after each comma in the list.
Note: If an table that satisfies a wildcard is listed elsewhere in the configuration file, that entry overrides the processing or routing specified in the wildcarded entry. In this case, a not clause is not needed. See the Examples. |
tgt_schema.wildcard_name |
- tgt_schema is the schema of the target tables.
- wildcard_name is the wildcarded name of the target tables.
The target specification must be in the form of schema.%. Partially expanded target wildcarded names are not supported, such as schema.tab%. |
routing_map |
Any valid routing map. |
Validate a Wildcard Specification
To confirm that a wildcard specification will produce the specific list of tables that you want to replicate, issue the verify config command in sp_ctrl before you activate the configuration. This command produces a list of the tables that SharePlex will capture and replicate, as well as any problems that occurred. For more information about this command, see SharePlex Reference Guide.
Examples
Examples of valid wildcard specifications
Example 1: The following wildcard specification directs SharePlex to activate all tables owned by scott, where the table name is like prod% except if the table name is like %temp%. All tables that match this description are replicated to tables of the same names on the target in the hal schema.
Datasource:r.dbname
expand scott.prod% not (%temp%) hal.% hostB@r.dbname
Example 2: The following example shows how you can specify special handling for one of the tables in a wildcarded specification, in this case the photo table. All tables but photo are routed through the default post queue. The separate entry for the photo table overrides the wildcarded entry and processes the photo table through a named post queue.
Datasource:r.dbname
cust.% cust.% hostB@r.dbname
cust.photo cust.photo hostB:queuename@r.dbname
The following are additional examples of valid wildcard specifications for PostgreSQL to PostgreSQL replication:
Datasource:r.dbname
expand scott.%test% scott.% hostB@r.dbname
Datasource:r.dbname
expand scott.%t__t% fred.% hostB@r.dbname
Datasource:r.dbname
expand scott.% not (spo%, gen%, prodct) scott.% hostB@r.dbname
Datasource:r.dbname
expand scott.prod% not (%temp%) hal.% hostB@r.dbname
The following is an example of valid wildcard specifications for PostgreSQL to Oracle replication:
Datasource:r.dbname
expand "scott"."%test%" "scott"."%" hostB@o.target_dbname
The following is an example of valid partial wildcard specifications for PostgreSQL to SQL Server replication:
Datasource:r.dbname
expand scott.%test% scott.%test% hostB@r.target_dbname
Examples of invalid wildcard specifications
The following example contains a wildcarded schema, which is not permitted.
Datasource:r.dbname
expand rob%.%test% scott.% hostB@r.dbname
The following example contains a partially wildcarded target table name, which is not permitted.
Datasource:r.dbname
expand scott.%test% scott.%obj% hostB@r.dbname
Define a Unique Key for Oracle Database
Define a Unique Key
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.
|
Define a unique key - Oracle to Oracle
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
Define a unique key - PostgreSQL to PostgreSQL
The columns that you specify as a key must meet the following criteria:
-
A unique key cannot be TEXT, BYTEA, JSON, JSONB, CHAR with more than 2000 characters, VARCHAR without size or more than 4000 characters.
- 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.
- Create an index on the target table, it 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_schema.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_schema.table !key (col_name, col2_name, ...) |
tgt_schema.table |
host@r.dbname |
Example
Datasource:r.dbname
scott.tab !key(name,ID) scott.tab2 sysB@dbname
Define a unique key - PostgreSQL to Oracle
The columns that you specify as a key must meet the following criteria:
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_schema.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_schema.table !key (col_name, col2_name, ...) |
tgt_owner.table |
host@o.SID |
Example
Datasource:r.dbname
"scott"."tab" !key(name,ID) "scott"."tab2" sysB@o.oraB
Filter DML operations for Oracle Database
You can configure SharePlex to filter out the following DML from replication when wildcarding is being used.
- Oracle DML type (INSERT, UPDATE, DELETE)
- DML related to Oracle sequences and Oracle SQL*Loader direct-path loads.
Filter out a DML type
You can configure SharePlex to filter any type of DML operation so that the operation is not replicated to the target table. DML filtering is compatible with most other SharePlex configuration syntax.
Configure a DML filter
To configure a DML filter, add the following syntax to the source table specification. Leave a space between the table specification and the filter specification. You can specify multiple operation types to filter. Any additional syntax for other features, such as a column list or key definition, must follow the DML filter specification.
!dml(DML_type[,DML_type][,...])
Where DML_type is one of the following:
i |
INSERT |
d |
DELETE |
u |
UPDATE |
Examples
Example 1
The following example filters DELETE operations from being replicated to the target table.
Datasource:o.ora |
|
|
scott.emp !dml(d) |
scott.emp |
prodsys@o.sysdb |
Example 2
The following example filters DELETEs and INSERTs so that only UPDATEs are replicated to the target table. This example also shows how a DML filter is compatible with a column mapping specification.
Datasource:o.ora |
|
|
scott.stock !dml(d,i) (ID, name) |
scott.stock (SKU, prod) |
sys2@o.sysdb |
View current DML filters
Use the verify config command to view the DML that is being filtered for each table in the configuration file. This command can be used for an active or inactive configuration file.
sp_ctrl> verify config myconfig
7: "SCOTT"."EMP" "SCOTT"."EMP" prodsys@o.proddb
Filter out >>>>> DELETES
Unique Key : (EMPLOYEE_ID)
Restrictions
Filter DML related to specific Oracle objects from replication
You can prevent SharePlex from replicating sequences and SQL*Loader direct-path loads. By default the replication of these objects is enabled.
Sequences |
SP_OCT_REPLICATE_SEQUENCES |
0 |
SQL*Loader direct-path loads |
SP_OCT_REPLICATE_DLOAD |
0 |
Filter DML Operations for PostgreSQL Database
You can configure SharePlex to filter out the PostgreSQL DML type (INSERT, UPDATE, DELETE) from replication when wildcarding is being used.
Filter out a DML type
You can configure SharePlex to filter any type of DML operation so that the operation is not replicated to the target table. DML filtering is compatible with most other SharePlex configuration syntax.
Configure a DML filter
To configure a DML filter, add the following syntax to the source table specification. Leave a space between the table specification and the filter specification. You can specify multiple operation types to filter. Any additional syntax for other features, such as a column list or key definition, must follow the DML filter specification.
!dml(DML_type[,DML_type][,...])
Where DML_type is one of the following:
i |
INSERT |
d |
DELETE |
u |
UPDATE |
Examples
Example 1
The following example filters DELETE operations from being replicated to the target table.
Datasource:r.dbname |
|
|
scott.emp !dml(d) |
scott.emp |
prodsys@r.dbname |
Example 2
The following example filters DELETEs and INSERTs so that only UPDATEs are replicated to the target table. This example also shows how a DML filter is compatible with a column mapping specification.
Datasource:r.dbname |
|
|
scott.stock !dml(d,i) !key (EMPLOYEE_ID) |
scott.stock |
sys2@r.dbname |
View current DML filters
Use the verify config command to view the DML that is being filtered for each table in the configuration file. This command can be used for an active or inactive configuration file.
sp_ctrl> verify config myconfig detail
7: "SCOTT"."EMP" "SCOTT"."EMP" prodsys@o.proddb
Filter out >>>>> DELETES INSERTS
Unique Key : (EMPLOYEE_ID)
Restriction
If there are multiple specifications of a source table in the configuration file, the DML filter specification specified in the last line for the table is considered.