When you select the objects to be synchronized in a data synchronization task, you can specify SQL conditions to filter data. Only the data that meets the specified conditions is synchronized to the destination database. This feature is applicable to scenarios such as regular data synchronization and table partitioning.

Prerequisites

A data synchronization task is configured. The current step is Select Objects to Synchronize. For more information about how to create and configure a data synchronization task, see Create a data synchronization task.

Limits

  • You can filter only the fields in the current table. Cross-table filtering is not supported.
  • If the source database is a self-managed PostgreSQL database, an ApsaraDB RDS PostgreSQL instance, or a PolarDB-O cluster, filtering conditions do not take effect on incremental data.

Procedure

  1. In the Select Objects to Synchronize step, move the required objects to the Selected section, move the pointer over a table, and then click Edit. Select a table
  2. In the Edit Table dialog box, enter an SQL condition in the Filter field. Enter an SQL condition
    Note
    • An SQL condition is a standard SQL WHERE statement. The following operators are supported: =, !=, <, >, and in. Only the data that meets the WHERE condition is synchronized to the destination database. In this example, enter orderid>100.
    • You can specify a time condition in an SQL WHERE statement. However, you must make sure that the specified time condition is valid. For example, to filter incremental data created after 2020, you must enter create_time>'2020-01-01' or create_time>'2020-01-01 00:00:00'. You cannot enter create_time>'2020'.
    • You can use apostrophes (') in an SQL condition if necessary. For example, you can enter address in('hangzhou','shanghai').
  3. Click Verify to check whether the syntax is valid.
    Note
    • If the syntax is valid, the Information message shows that the validation is passed.
    • If the syntax is invalid, the Error message appears. In this case, you must modify the condition based on the instructions.
  4. Click OK.
  5. Configure other parameters that are required for the data synchronization task.