Object name mapping

更新时间:
复制 MD 格式

When you configure a data synchronization or migration task, you can use the object name mapping feature of Data Transmission Service (DTS) to specify the names of objects, such as databases, tables, and columns, in the destination instance. This feature lets you synchronize or migrate data to specific objects in the destination instance, or to create new objects in the destination instance that have the same schema as the source objects but different names.

Use cases

Note

The following scenarios also apply when the source and destination databases reside in the same database instance. In this case, data isolation is required. For example, you can isolate data using different database or table names.

Scenario

Description

Create an object in the destination database to receive data.

  • Data migration task: You must select Schema Migration for the Migration Types parameter, and select at least one of Full Data Migration and Incremental Data Migration.

  • Data synchronization task: By default, Incremental Data Synchronization is selected for the Synchronization Types parameter. You must also select Schema Synchronization, and select Full Data Synchronization as needed.

Specify the objects in the destination database that will receive the data. For example, you can aggregate data from multiple tables into a single large table.

You must create an object in the destination database in advance to receive data and ensure data compatibility.

  • Data migration task: You do not need to select Schema Migration for the Migration Types parameter.

  • Data synchronization task: You do not need to select Schema Synchronization for the Synchronization Types parameter.

Create an object in the destination database.

This scenario is supported only for data migration tasks. You need to select only Schema Migration for the Migration Types parameter.

Prerequisites

The task is in the Configure Objects stage, and you need to perform database, table, and column mapping. For information about how to enter the Configure Objects stage, see the related configuration documents in Synchronization Solution Overview and Migration Solution Overview.

Note
  • We recommend that you select all options for Migration Types or Synchronization Types. Otherwise, the synchronization or migration results may not meet your expectations.

  • The legacy configuration page must be at the Configure Objects and Advanced Settings step.

Usage notes

  • Do not map object names after the task starts, as this might cause data loss or task failure.

  • For Tair or Redis instances, only database name mapping is supported. You can specify a destination database from DB 0 to DB 255 to receive data.

  • When the destination database type is DataHub, database name mapping is not supported.

  • When the target database type is Kafka, if you use the mapping feature to modify the Table Name, the data is written to the topic that you specify. You must ensure that the topic name that you enter in the Table Name field exists in the target Kafka instance. Otherwise, the task will fail.

  • If you select entire databases as the objects to synchronize or migrate, only database name mapping is supported.

  • If you need to use table name or column name mapping, the selection granularity for task objects must be collection for MongoDB source databases, Redis DB for Tair/Redis source databases, and table for other database types.

  • If you use object name mapping, the synchronization or migration of other objects that depend on the mapped object might fail.

Map a single object name

  1. Move the task objects from the Source Objects area to the Selected Objects box.

  2. Open the mapping dialog box for the database or table.

    • Right-click the target object in the Selected Objects area.

    • Hover over the target object, and click the Edit button that appears.

  3. In the dialog box that appears, change the name of the object for the destination instance.

    Note
    • When you map database or table names for certain instances, you can also add extra columns and filter SQL statements (DML and DDL) for incremental tasks. The specific features available depend on the console.

    • If you select different SQL statements for database name mapping and table name mapping, the statements selected for table name mapping take precedence.

    • You can also configure conditions to filter task data in the Edit Table dialog box. For more information, see Set Filter Conditions.

    • Database name mapping

      In the Edit Schema dialog box, set the name of the database in the destination instance.

      Note

      When the source and destination database types are both SQL Server, the Edit Database Name dialog box appears.

    • Table name mapping

      In the Edit Table dialog box, set the name of the data table in the destination instance.

      Note

      If the destination instance is Elasticsearch, the only special character supported in index and type names is the underscore (_).

    • Column name mapping

      In the Edit Table dialog box, in the Column area, set the Destination Column Name for the corresponding column in the destination instance.

      For example, you can map the source column id to id_new and name to name_new.

  4. Click OK.

  5. Complete the remaining configuration steps.

Map multiple object names in batch

  1. Move the task objects from the Source Objects box to the Selected Objects box.

  2. Click Batch Edit in the upper-right corner of the Selected Objects area.

  3. In the Batch Edit dialog box, you can batch map the names of databases or tables as needed.

    Source database type: Tair/Redis

    1. In the Select Objects box, select the objects that you want to edit.

      Note

      The batch edit type defaults to Include Only Selected Databases.

    2. Optional: In the Select Editing Type section, click the Object Name tab.

    3. Select the scope for the change.

      • Edit Renamed Object Name: Indicates that the batch modification is applied to the database names that have already been renamed.

      • Edit Original Object Name: Specifies that the new database names are generated by modifying the original names.

    4. Select a rule for the name change and configure the new name.

      • Add a prefix or suffix to the name: For Select Rule, select Add Prefix and Suffix, and enter the prefix and suffix.

      • Batch rename: Set Select Rule to Change All Names, and enter the new name.

      • Remove a specific part from all names: Set Select Rule to Shorten All Names, and enter the keyword to remove.

    5. Click Apply to add the configured batch mapping rules.

    6. Click OK.

    When the source database is SQL Server

    1. Select the batch edit type.

      This example selects Select All Databases and Tables.

    2. In the Select Objects box, select the objects that you want to edit.

    3. Optional: In the Select Editing Type section, click the Object Name tab.

    4. Optional: Select an object name type.

      Note

      You can configure Select Object Type only if on the Configure Objects page, the Schema Mapping Mode of Source and Destination Databases is set to Use <Source schema name>.<Source table name> as the destination table name, or if the Configure Objects page does not have the Schema Mapping Mode of Source and Destination Databases configuration item.

      • Database/Table Name: Modifies the name mapping for only databases and tables in the selected objects.

      • Schema Name: Modifies the mapping of only the schema names in the selected objects.

    5. Select the scope for the change.

      • Edit Renamed Object Name: Indicates that the batch modification is applied to the renamed object names.

      • Edit Original Object Name: Modifies the library names based on their original names.

    6. Select a rule for the name change and configure the new name.

      • Add a prefix or suffix to the name: For Select Rule, select Add Prefix and Suffix, and enter the prefix and suffix.

      • Batch rename: Set Select Rule to Change All Names, and enter the new name.

      • Remove a specific part from all names: Set Select Rule to Shorten All Names, and enter the keyword to remove.

    7. Click Apply to add the configured batch mapping rules.

    8. Click OK.

    Other database types

    1. Select the batch edit type.

      This example selects Select All Databases and Tables.

    2. In the Select Objects box, select the objects that you want to edit.

    3. Optional: In the Select Editing Type section, click the Object Name tab.

      Note

      For certain instances, batch mapping also allows you to add extra columns and filter SQL statements (DML and DDL) for incremental tasks. The specific features available depend on the console.

    4. Select the scope for the change.

      • Edit Renamed Object Name: The batch modification is applied to the previously renamed names of databases, tables, and columns.

      • Edit Original Object Name: Indicates that the names of databases, tables, and columns are modified based on their original names in a batch operation.

    5. Select a rule for the name change and configure the new name.

      • Add a prefix or suffix to the name: For Select Rule, select Add Prefix and Suffix, and enter the prefix and suffix.

      • Batch rename: Set Select Rule to Change All Names, and enter the new name.

      • Remove a specific part from all names: Set Select Rule to Shorten All Names, and enter the keyword to remove.

    6. Click Apply to add the configured batch mapping rules.

    7. Click OK.

  4. Complete the remaining configuration steps.

Synchronize or migrate specific columns

Important

In table merging scenarios, where data from multiple tables is synchronized or migrated to a single destination table, using this feature may cause task failure or data inconsistency.

  1. Move the tables to synchronize or migrate from the Source Objects box to the Selected Objects box.

  2. Right-click the target object in the Selected Objects area to open the table mapping interface.

  3. In the Edit Table dialog box, under Columns, deselect Sync All Columns.

    Select the columns to synchronize, such as id (bigint) and name (varchar(20)), and, if needed, modify their names in the Destination Column Name box.

  4. Deselect the columns you do not want to synchronize or migrate.

  5. Click OK.

  6. Complete the remaining configuration steps.

FAQ

  • How do I filter out columns that I do not want to synchronize or migrate?

    To use column name mapping, deselect Sync All Columns, and then deselect the checkbox for the corresponding column.

  • Can I change a column's data type by using column name mapping?

    No.

  • Can I modify an existing batch editing rule?

    No. You can click the delete icon image.png next to the rule to remove it, and then add a new one.

  • Why did my batch editing rule disappear?

    This may be because you did not click Apply after you configured the batch mapping rules, or you accidentally deleted the rules.