# Configuring a `DM` Task: Table Routings

+ The table routing feature enables `DM` to migrate a certain table of the upstream `MySQL` compatible instance to the specified table in the downstream `TiDB`
+ Define a global table routing parameters set by using **`routes`** in the task configuration file
  + **`schema-pattern:`** The pattern of the data source schema name
  + **`table-pattern:`** The pattern of the data source table name
  + **`target-schema:`** The pattern of the downstream `TiDB` schema name
  + **`target-table:`** The pattern of the downstream `TiDB` table name
+ Reference the table routing rules in the data source configuration to assign the routes
```
~!@# Global Routing Parameters@!~
routes: 
  ~!@route-rule-1@!~:
    schema-pattern: "test_*"
    table-pattern: "t_*"
    target-schema: "test"
    target-table: "t"
  ~!@route-rule-2@!~:
    schema-pattern: "test_*"
    target-schema: "test"
```
```
~!@# Reference the Table Routings@!~
mysql-instances:
  - source-id: ~!@"mysql-replica-01"@!~
    block-allow-list:  "bw-rule-1"
    filter-rules: ["filter-rule-1"]
    route-rules: ~!@["route-rule-1", "route-rule-2"]@!~
```
```
```
-------------------------------------------------------------
Table routing provides the ability to migrate some tables from an upstream `MySQL/MariaDB` instance to a specified downstream table.

Setting multiple different routing rules for the same table is not supported.

Schema matching rules need to be set separately such as `rule-2` in the following parameter configuration examples.

Migrates the tables of the upstream `MySQL/MariaDB` instance that match the rule according to schema-pattern/table-pattern to the downstream target-schema/target-table.

Assuming there is a database sharding scenario, you need to add the table `test*{1,2,3...}.t* {1,2,3...}` of the two upstream `MySQL` instances `A` table `test.t` migrated to downstream `TiDB`.

In order to migrate the table `test.t` to the downstream instance, you need to create the following table routing rule:
- `rule-1` is used to migrate `DML/DDL` statements from tables that match the upper schema-pattern: `"test_*"` and table-pattern: `"t_*"` to the downstream `test.t`.
- `rule-2` is used to migrate `DDL` statements for the database  that match the schema-pattern: `"test_*"`, for example, `CREATE/DROP SCHEMA test_1`.

In the example on slide:
- If the downstream `TiDB` schema: test already exists and will not be deleted, `rule-2` can be omitted.
- If the downstream `TiDB` schema: test does not exist and only `rule_1` is set, the migration will report an error schema test doesn't exist.