Skip to main content

Import Replication Object Templates

When you create a replication task, you can use an Excel configuration template to import multiple replication objects in bulk. The template supports exact table names, table-name regular expressions, and capture-group substitutions for target table names.

Before you begin

  • Add the source and target data sources to NineData. For details, see Add Data Source.
  • Confirm that the selected replication link supports custom replication objects and configuration import.
  • Prepare the source database name, source table name, target database name, and target table name. Make sure your account can read source-object metadata.

Procedure

  1. In the navigation menu, click Replication > Data Replication.

  2. On the Replication page, click Create Replication.

  3. On the Source & Target tab, configure the task name, source data source, target data source, and replication type, and then click Next.

  4. On the Objects tab, select Customized Object, and then click Import Config.

  5. In the import dialog:

    1. Click Download Template to download the Excel template.
    2. Fill in the template without deleting or renaming its columns. Each row represents one object to import.
    3. Click Upload and select the edited Excel file.
    4. Click Import Config to import the configuration.

    If you use a table-name regular expression, click How to use to view the usage instructions provided by the current console.

Parameters

ParameterDescriptionExample
source_table_nameThe source table name. An exact table name matches one table; a table-name regular expression can match multiple tables.example_tbl_name
target_table_nameThe target table name. When using a regular expression, use capture groups such as $1 and $2 to substitute parts of the target table name.target_$1
source_database_nameThe source database name.test_db
target_database_nameThe target database name.test_db_bak
column_listThe list of columns to synchronize.["col1", "clo2", "col3"]
extra_configurationA JSON string containing additional configuration. Use column_rules for column mappings and value rules, and filter_condition for row-level filtering.{"extra_config": {"column_rules": [...]}}
tip

The following JSON represents the two complete example rows in the downloaded Excel template. When uploading the file, keep the Excel column names and enter the extra_configuration value as a JSON string. This code block is not a JSON file that you can upload directly.

[
{
"source_table_name": "example_tbl_name",
"target_table_name": "example_tbl_name",
"source_database_name": "test_db",
"target_database_name": "test_db_bak",
"column_list": ["col1", "clo2", "col3"],
"extra_configuration": {
"extra_config": {
"column_rules": [
{
"column_name": "example_column_name",
"target_column_name": "example_target_column_name",
"target_column_type": "int",
"column_value": "current_timestamp()"
},
{
"column_name": "example_column_name",
"target_column_name": "example_target_column_name",
"target_column_type": "int"
}
],
"filter_condition": "example_condition_expression"
}
}
},
{
"source_table_name": "^example_(.*)$",
"target_table_name": "target_$1",
"source_database_name": "test_db",
"target_database_name": "test_db_bak",
"column_list": ["col1", "clo2", "col3"],
"extra_configuration": {
"extra_config": {
"column_rules": [
{
"column_name": "example_column_name",
"target_column_name": "example_target_column_name",
"target_column_type": "int",
"column_value": "current_timestamp()"
},
{
"column_name": "example_column_name",
"target_column_name": "example_target_column_name",
"target_column_type": "int"
}
],
"filter_condition": "example_condition_expression"
}
}
}
]

The following fields can be used in extra_configuration:

  • column_name: The source column name.
  • target_column_name: The target column name.
  • target_column_type: The target column type.
  • column_value: The column value, which can be an SQL function or a constant value.
  • filter_condition: A row-level data filtering condition.

For example, enter the following JSON string in an extra_configuration cell:

{
"extra_config": {
"column_rules": [
{
"column_name": "example_column_name",
"target_column_name": "example_target_column_name",
"target_column_type": "int",
"column_value": "current_timestamp()"
}
],
"filter_condition": "example_condition_expression"
}
}

Table-name regular expressions

When source_table_name contains a regular expression, target_table_name can use capture groups to build the target table name. For example:

source_table_name: ^t0(.*)$
target_table_name: target_t0$1

This example replaces a matching t001 with target_t001. Make sure the regular expression matches tables in the source data source. During import, NineData checks for source tables that do not exist and table-name regular expressions that do not match any source table.

Result

After the import, return to the object selection page and review the source and target object lists. If a source table does not exist or a table-name regular expression does not match a source table, NineData displays the validation result with the source table name, target table name, source database name, and target database name. Update the Excel file and import it again, or click Cancel Import to cancel the import. When the configuration is correct, click Continue Import to continue.