AWS now supports new data transformation capabilities in the latest AWS Database Migration Service (AWS DMS) version 3.1.3. You can change schema, table, and column names; specify individual tablespace names for Oracle targets; and update a table’s primary and unique key on any target. DMS version 3.1.3 supports the following new data transformation capabilities:
- Explicit table mapping
- Transformation rules for tablespaces for Oracle source and target
- Transformation rules for index tablespaces for Oracle source and target
- Defininition of the primary key or unique key index
- Data type modification of the target column
Explicit table mapping
In previous DMS versions, you used the AWS Management Console to perform table mapping, specify table selections, or transform rule-actions on schemas and tables.
With 3.1.3, AWS DMS allows you to perform explicit table selection. Explicit table mapping rules allow you to select a specific source table for migration to supported DMS targets. It also excludes subsets of tables from the source for better granularity. When using explicit selection rules, you can’t use wildcards (%) for schema and table names in the table mapping.
In the following example, the source has seven tables. Using the explicit transformation rule, you can choose to migrate the DEPT table only, while excluding the remaining tables from migration.
The corresponding transformation rule in the DMS console looks like the following:
You can query for the table ‘DEPT’ on the target database schema using the following query:
Transformation rule for tablespace for Oracle source and target
Transformation rules for tablespace allow you to migrate tables to a specific tablespace on an Oracle target. The following code example lets you put the table
MYTABLENAME into a separate tablespace.
Transformation rules for index tablespaces for Oracle source and target
Transformation rules for index tablespaces allow you to migrate table indexes to a tablespace on your choice on an Oracle target. The following code example allows you to put the index for table
MYTABLENAME into a separate tablespace.
Definition of the primary key or unique index
Managing and creating primary keys on table columns presents a constant challenge. New DMS functionality allows you to update the primary key on a target.
The following example shows you how to create a table primary key on the required columns. The column order defined in the transformation rule indicates the column order in the primary key created on the target. You can specify the origin field to create the key on the target as either a primary key or a unique index. DMS creates it as a primary key by default.
In this example, ID is the only primary key column on the source. You can use this sample table mapping rule to migrate SNO as the primary key as well:
On the target end, this code example creates table DMS with both ID and SNO as primary keys. The syntax for the primary key constraint looks like the following:
Data type change for the target column
You can transform the type of a column on the fly using the change-data-type transformation during the migration. DMS now supports data type transformations for the following data types:
In the following example, I use SQL Server as the source and target to demonstrate how to change the column data types with the target transformation rule.
Step 1: Create a source table
Use the following code example to create a table on the source:
Step 2: Create a task
Use the following task-mapping JSON to create a task using the following source and target endpoint:
Step 3: Modify the table.
The transformation rules should modify your table to the following:
AWS DMS replication engine version 3.1.3 makes the features in this post available to you. You can use explicit mapping rules (all engines), different transformation rules for Oracle source and target, and define primary key and unique key indexes on the target columns for all engines.
If you have questions or suggestions, add your comments below. Good luck and happy migrating!
About the Author
Harish Bannai is a cloud support engineer at AWS. He works with customers to provide guidance and technical assistance on database projects, helping them to improve the value of their solutions when using AWS..