# Table Routings

__*Using DM*__
__*Table routings*__

+ Example

```
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"
```
-------------------------------------------------------------
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.