AWS Database Blog
Validate database objects after migrating from SAP ASE to Amazon RDS for MySQL, Amazon RDS for MariaDB, or Amazon Aurora MySQL
In this post, we focus on database object validation for the heterogenous migration from SAP ASE to Amazon Relational Database Service (Amazon RDS) for MySQL, Amazon RDS for MariaDB, or Amazon Aurora MySQL-Compatible Edition.
For schema conversion and migration, you can use AWS Schema Conversion Tool (AWS SCT). AWS SCT helps convert your database schema from the source database into a format compatible with your preferred target database. If the schema from your source database can’t be converted automatically by any means, AWS SCT provides helpful guidance on how to address the challenges to create an equivalent schema for your target.
Because this is a semi-automated process, post-migration schema validation plays a vital role in ensuring that all database objects are migrated successfully as intended.
Prerequisites
The following prerequisites are required to perform the post-migration validation provided in this post:
- A SAP ASE source database.
- An RDS for MySQL, RDS for MariaDB, or Aurora MySQL target database post migration.
- An Amazon Elastic Compute Cloud (Amazon EC2) instance or a SQL client with necessary permissions to connect to both source and target databases and run the validation SQLs.
- A database user with public access to the primary database on the source SAP ASE database. The user must have SELECT permissions on the following system tables:
[source_db].dbo.sysobjects
[source_db].dbo.syscolumns
[source_db].dbo.sysconstraints
[source_db].dbo.syspartitionkeys
[source_db].dbo.sysindexes
[source_db].dbo.sysreferences
[source_db].dbo.sysusers
master.dbo.spt_values
- A database user with read privileges to the target database. The user must have
SELECT
permissions on theINFORMATION_SCHEMA
tables.
Database object identification and validation
After you complete the database schema migration from the source schema objects of SAP ASE to their equivalent MySQL schema objects, you need to validate the schema objects to reduce issues during the final stages of migration.
To perform these validations, you first need to understand the different types of database objects that need to be considered. You can compare the following database objects between SAP ASE and the corresponding RDS for MySQL or MariaDB database:
- Schemas
- Tables
- Functions
- Views
- Stored procedures
- Indexes
- Triggers
- Constraints
- Primary key constraints
- Foreign key constraints
- Check constraints
- Default constraints
In the following sections, we look into each of these object types and validate them using their corresponding SQL queries to help us identify any mismatch in the migrated schema objects.
You can use the AWS SCT assessment report or its log file to identify the reason for failure if you find differences between any of the database objects. Then convert and create the respective objects to the target database equivalent manually. You need to manually correct the SQL scripts to replace the target equivalent syntax for table partitions before running them on the target database.
The queries we use in these sections exclude system schemas in the source and target databases. We cover summary-level as well as detail-level validations, wherever applicable. You can further modify these queries to include more scrutiny as required.
Schemas
In SAP ASE, the default scheme is called dbo
. If any user-defined schema is present, it’s the same as the user name of the specific user who is authorized to access objects in that schema. All database objects in SAP ASE have an owner; this object owner is effectively the same thing as a schema in MySQL.
You can validate the schema at the source (SAP ASE) and target (MySQL or MariaDB) using the following SQL queries.
Use the following SQL query for SAP ASE:
The following screenshot is an example of the SAP ASE output.
The following is a similar query for MySQL or MariaDB.
You get the following output.
Verify the schema result for any possible differences between the source and target databases using the aforementioned queries. If you find any differences, identify the root cause or take guidance from the AWS SCT logs and fix them accordingly. In this example, the output is as expected; no issues were detected, so you can move to the next level of validation.
Extension packs
When you convert your database or data warehouse schema using AWS SCT, it may add additional schemas to your target database. This additional schema, known as an extension pack, implements SQL system functions of the source database that are required when writing your converted schema to your target database. When migrating your database from SAP ASE to Amazon RDS for MySQL, Amazon RDS for MariaDB, or Aurora MySQL, AWS SCT creates an extension pack named aws_sapase_ext
, as seen in the following example.
The following SQL query is for MySQL or MariaDB.
You get the following output.
AWS SCT can automatically apply an extension pack when you apply a target database script. You can do this manually as well. We have excluded the extension pack schema in all other validation queries because it’s captured in this section.
Tables
In this section, we discuss tables under each schema (or owner) and detailed information for each table.
AWS SCT converts source SAP ASE tables to the equivalent MySQL or MariaDB target tables with appropriate data types and relative table definitions as per the target database syntax. To ensure that all the tables were migrated successfully, you can use the following SQL queries, which return the schema and count of all the underlying tables.
Use the following SQL query for SAP ASE.
You can see sample output in the following screenshot.
The following is a similar query for MySQL or MariaDB.
You get the following output.
Verify the table count for any possible differences between the source and target databases using the aforementioned queries. If you find any differences, identify the root cause or take guidance from the AWS SCT logs and fix them accordingly.
Detailed information for each table
Validating the count of the tables under the schema or object owner is not enough to conclude that all tables are migrated properly. The following query helps verify a few key features of the tables involved in the migration, such as the presence of LOB columns, computed columns, partitions, and column count.
Use the following SQL query for SAP ASE.
The following screenshots show our output.
The following is a similar query for MySQL or MariaDB.
You get the following output.
Verify the table details for any possible differences between the source and target databases using these queries. If you find any differences, identify the root cause or take guidance from the AWS SCT logs and fix them accordingly.
Views
A view is a logical table created by a query joining one or more tables. You can validate the views by using the following queries on the source and target databases.
Use the following SQL query for SAP ASE.
You get the following output.
The following is a similar query for MySQL or MariaDB.
You get the following output.
Verify the view result for any possible differences between the source and target databases using these queries. If you find any differences, identify the root cause or take guidance from the AWS SCT logs and fix them accordingly.
Functions
Functions implement specific business or functional logic based on the given input and return a predefined format of output. The following SQL queries give you the details of functions for both the source and target databases.
Use the following SQL query for SAP ASE.
You get the following output.
The following is a SQL query for MySQL or MariaDB.
The following screenshot shows the query output.
Verify the function results for any possible differences between the source and target databases using these queries. If you find any differences, identify the root cause or take guidance from the AWS SCT logs and fix them accordingly.
Stored procedures
A stored procedure is a collection of pre-compiled SQL statements stored in a database memory for quick access from an application program. The following SQL queries give you the count and details of stored procedures for both the source and target databases.
Use the following SQL query for SAP ASE.
You get the following output.
The following is a SQL query for MySQL or MariaDB.
The following screenshot shows the output.
Verify the procedure information for any possible differences between the source and target databases using these queries. If you find any differences, identify the root cause or take guidance from the AWS SCT logs and fix them accordingly.
Indexes
Indexes in database systems play an important role in overall system performance. Although indexes can improve performance of read operations, they also hinder write operations. Choosing the right indexing strategy is key.
With the following queries, you can get the list of indexes and their types in both SAP ASE and MySQL databases.
Please note, primary keys aren’t included in the following SQL query because we validate it later in this post as a constraint.
Use the following SQL query for SAP ASE.
The following screenshot shows the output.
You can use the following SQL query to fetch index information for MySQL or MariaDB.
The following screenshot shows the output.
The SAP ASE result has an extra column (IndexDescription
) categorizing the indexes as clustered or non-clustered, whereas the equivalent can’t be done in MySQL because the indexes other than clustered (synonymous with primary key or unique index) are known as secondary indexes. For this verification, the details until the IndexType
column should suffice.
Verify the index details for any possible differences between the source and target databases using these queries. If you find any differences, identify the root cause or take guidance from the AWS SCT logs and fix them accordingly.
Triggers
Triggers are a special type of stored procedure that defines a set of actions performed in response to an insert, update, or delete operation on a specified table. The following queries give you the details of triggers for both the SAP ASE and MySQL databases.
Use the following SQL query for SAP ASE.
You get the following output.
Use the following SQL query for MySQL or MariaDB.
You get the following output.
Verify the trigger details for any possible differences between the source and target databases using these queries. If you find any differences, identify the root cause or take guidance from the AWS SCT logs and fix them accordingly. If the source database has multiple trigger events (insert, update, delete) in a single trigger, it needs to be created as multiple separate triggers in MySQL, because it doesn’t support them all in a single trigger. In this case, the trigger count and the trigger name details may not match with the source.
Constraints
Constraints offer the advantage of defining integrity controls in one step during table creation and simplifying the creation of those integrity controls. This ensures the accuracy and reliability of the data in the table. However, integrity constraints are more limited in scope and less comprehensive than indexes and triggers.
Primary key constraint
Use the following SQL query for SAP ASE.
You get the following output.
Use following SQL query for MySQL or MariaDB.
The following screenshot shows the output.
Foreign key constraint
Use the following SQL query for SAP ASE.
You get the following output.
The following is a similar SQL query for MySQL or MariaDB.
You get the following output.
Check constraint
Use the following SQL query to get a summary of check constraints on the SAP ASE database:
You get the following output.
The following is a similar query for MySQL or MariaDB.
You get the following output.
Default constraint
Use the following SQL query for SAP ASE.
You get the following output.
The following is a similar query for MySQL or MariaDB.
You get the following output.
Verify the constraint details for any possible differences between the source and target databases using these queries. If you find any differences, identify the root cause or take guidance from the AWS SCT logs and fix them accordingly.
Conclusion
In this post, we showed how to verify if your SAP ASE database has been migrated correctly to Amazon RDS for MySQL, Amazon RDS for MariaDB, or Aurora MySQL. Use this post if you’re experiencing issues in object validation or as a reference guide while migrating from an SAP ASE database to an RDS for MySQL, RDS for MariaDB, or Aurora MySQL database.
We recommend building these validation steps into your workflow for a smoother migration experience. Note that the SQLs were tested against SAP ASE 15.7, MySQL 8.0.28, and MariaDB 10.6.7; the results may vary on other versions.
If you have any comments or questions, leave them in the comments section.
About the authors
Pavithra Balasubramanian is a Database Consultant with Amazon Web Services in India. She is passionate about helping customers in their cloud adoption journey with a focus on legacy database migrations to AWS cloud.
Nishad Mankar is a Database Consultant with AWS Professional Services. He helps customers to migrate and modernize their databases on AWS Cloud.
Amit Kumar is a Database Consultant with AWS Professional Services based out of Hyderabad, India. With good knowledge on relational databases adding hands-on in homogenous and heterogenous database migrations and optimization in AWS cloud.