Data Comparison of Tables with the Same Name in Different Databases Using sync-diff-inspector

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: sync-diff-inspector不同库同表名数据对比

| username: TiDBer_OB4kHrS7

[TiDB Usage Environment] Production Environment / Testing / Poc
[TiDB Version]
[Reproduction Path] After using DM for synchronization, how to verify data consistency
[Encountered Problem: Problem Phenomenon and Impact] Now I want to verify the data consistency of tables with the same name in two different databases, but I don’t know how to configure target-check-tables.
[Resource Configuration] Go to TiDB Dashboard - Cluster Info - Hosts and take a screenshot of this page
[Attachments: Screenshots/Logs/Monitoring]

I want to verify the data of test.d_mem_qw_userid and test_prd.d_mem_qw_userid. How should target-check-tables be configured to compare them?
[data-sources]
[data-sources.oldtidb]
host = “XXXXXX”
port = 3306
user = “XXXXXX”
password = “XXXXX”
[data-sources.newtidb]
host = “XXXXX”
port = 4000
user = “XXXXX”
password = “XXXXX”
[routes]
[routes.rule1]
schema-pattern = “test”
table-pattern = “d_mem_qw_userid”
target-schema = “test_prd”
target-table = “d_mem_qw_userid”

[task]
output-dir = “/data/tools/tidb-toolkit-v5.3.2-linux-amd64/bin/output”
source-instances = [“oldtidb”]
target-instance = “newtidb”

Tables in the downstream database that need to be compared, each table needs to include the database name and table name, separated by .

target-check-tables = []
| username: 像风一样的男子 | Original post link

Check out this document on data validation for different database names or table names:

| username: TiDBer_OB4kHrS7 | Original post link

After reading the documentation, I don’t know how to configure target-check-tables = []. If it’s not configured, it says there are no tables to check.

| username: 江湖故人 | Original post link

target-check-tables = ["test_prd.d_mem_qw_userid"]

| username: 像风一样的男子 | Original post link

The target-check-tables is for writing the tables in the downstream database. You just need to write test_prd.d_mem_qw_userid.

| username: TiDBer_OB4kHrS7 | Original post link

It turns out that this configuration has been tried before, and it doesn’t work.

| username: 江湖故人 | Original post link

Can you post the complete configuration?

| username: TiDBer_OB4kHrS7 | Original post link

The image cannot be translated directly. Please provide the text content for translation.

| username: TiDBer_OB4kHrS7 | Original post link

You need to add a routing rule to the source address.

| username: 江湖故人 | Original post link

Yes, if the database names are inconsistent, you need to use routes.

| username: TiDBer_aaO4sU46 | Original post link

[routes.rule1]
schema-pattern = "schema_2"  # Matches the database name of the data source, supports wildcards "*" and "?"
target-schema = "schema"     # Target database name
| username: redgame | Original post link

I also see that a route is missing.

| username: TiDBer_5cwU0ltE | Original post link

Write a script and give it a try.