Filtering Table Rows for Selective Replication to Different Targets
By default, Data Replication replicates data from source tables to corresponding target tables on all of the target servers. However, you can define a filter that selects a subset of table rows to replicate to a particular target.
First define the group of source tables to filter, and then define the filter conditions for the table group.
Verify that the configuration is in Edit mode.
On the
Routing
tab, select a target server.
On the
Filters
subtab, click the
Add
icon button on the upper toolbar to add a group of tables.
The
New Table Group
dialog box appears.
In the
Group Name
field, enter a name for the table group.
Table group names can contain only the digits 0-9, Latin letters A-Z and a-z, and the underscore (_) character. The Data Replication Console truncates table group names that are longer than 100 characters.
In the
Schema
field, select a schema name or enter a mask for the schema name. A mask contains the asterisk (*) wildcard.
The lower left box lists the schemas that match your entry.
In the
Table
field, select a table name or enter a mask for the table name. A mask contains the asterisk (*) wildcard.
The lower right box lists the tables in the selected schema or schemas that match your table name entry.
In the lower list boxes, select the schemas and tables to which the filter will apply. Then click
OK
.
The
Filters
subtab displays the group name. The following image shows the
Filters
subtab with a new group name selected:
To add a filter condition, select the group name in the upper list box. Then click the
Add
icon button above the lower list box for columns and conditions.
The
Filter
dialog box appears.
To define a filter condition, perform the following steps:
In the
Column
field, define a column name mask to select the columns that are part of the filter.
You can enter only the asterisk (*) wildcard to include all columns.
Select a condition operator.
If the operator type requires a value to form the filter condition, enter the value in the field below the operator list. For example, if the operator is >, enter 1 to form the condition “greater than 1.”
For date and time columns, use the following format for the value:
yyyy
-
mm
-
dd
hh
:
mm
:
ss
.
If the operator type requires a second value, enter a value in the field after AND. For example, if the operator is BETWEEN, enter 5 before AND and 10 after AND to form the condition “between 5 and 10.”
Click
OK
.
The filter condition appears on the
Filters
subtab. The Data Replication Console prompts you to apply the filter condition.
Click
Yes
to apply the filter condition immediately. Click
No
if you want to apply the condition manually later.
To apply the filter condition manually, click
Apply
. Then click
Yes
at the confirmation prompt.
The right side of the
Filters
subtab shows the filter hierarchy. The subtab lists all of the tables and columns that match the filter criteria and the condition that is applied to each filtered column.
Repeat steps 1 through 8 for other target servers, as needed.
For Oracle sources, InitialSync creates a view for internal use when materializing targets with DBLinks. To filter data for a particular target, InitialSync executes SELECT statements with a WHERE clause for the view. To generate valid SELECT statements, set the
/uiconf/default.cfg file. If the file does not exist, use a text editor to create the file in the uiconf directory and then add the parameter in the file. For more information, see
Default.cfg File.
For each Oracle source table in a group, after you apply a filter condition, the Data Replication Console creates a virtual index that includes the columns for which the filter condition is defined, if a virtual index does not already exist. The virtual index is required to enable supplemental logging for the source tables. To name the virtual index, the Data Replication Console uses the table name followed by the _FILTER suffix.
If you create a filter for a particular target, Data Replication skips the source table rows that do not match the filter criteria when replicating changes to this target. If you later update at least one of the columns in a source table row that was previously filtered out for this target to a value that no longer meets the filter criteria, the source table row will be replicated to the target. However, for Oracle sources, any columns that are not in a supplemental log group created by Data Replication will have a null value in the replicated row on the target.
Data Replication applies the filters that you defined from the
Filters
subtab when the Send File task runs. If you add a filter after the Send File task ends, Data Replication does not apply the new filter to the replicated data.