AWS Database Blog
Validate database objects after migrating from SAP ASE to Amazon RDS for PostgreSQL or Amazon Aurora PostgreSQL
As part of this blog series, we previously covered database object validation for migrations from SAP ASE (previously known as Sybase ASE) as source to target databases like Amazon Relational Database Service(Amazon RDS) for SQL Server, Amazon RDS for MySQL, Amazon RDS for MariaDB, or Amazon Aurora MySQL-Compatible Edition. In the final post of this series, we focus on validating the migration from SAP ASE to Amazon RDS for PostgreSQL or Amazon Aurora PostgreSQL-Compatible Edition.
For this schema migration, you can use AWS Schema Conversion Tool (AWS SCT) as we did for the previous post except change the target database to Amazon RDS for PostgreSQL or Aurora PostgreSQL-Compatible.
Prerequisites
The following prerequisites are required to perform the post migration validation provided in this guide:
- A SAP ASE source database
- An Amazon RDS for PostgreSQL or Amazon Aurora PostgreSQL-Compatible 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 database 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
- The database user with read privileges to the target database. The user must have permissions on the following schema:
information_schema
pg_catalog
Database object identification and validation
To perform database object validation, you need to understand the different types of database objects to consider.
The following sections include database objects you can compare between SAP ASE and the corresponding PostgreSQL database. Schema validation also reduces issues during the last stages of migration.
- Schemas
- Tables
- Views
- Functions
- Stored procedures
- Indexes
- Triggers
- Constraints
- Primary key constraints
- Foreign key constraints
- Check 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.
Schemas
You can validate the schema at the source (SAP ASE) and target (PostgreSQL) 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 PostgreSQL:
You get the following output.
You can also use the following alternate query for PostgreSQL:
Verify the schema results for any possible differences between the source and target database using these 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.
Extension packs
When you convert your database schema using AWS SCT, it may add additional schemas to your target database, known as extension packs. When migrating your database from SAP ASE to Amazon RDS for PostgreSQL or Aurora PostgreSQL, AWS SCT creates an extension pack named aws_sapase_ext
, as seen in the following example.
The following SQL query is for PostgreSQL:
You get the following output.
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.
Tables under each owner
The migration tool (in this case AWS SCT) converts the source SAP ASE tables to the equivalent PostgreSQL target tables with the same or equivalent data types 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 the sample output in the following screenshot.
The following is a similar query for PostgreSQL:
You get the following output.
You can also use the following alternate query for PostgreSQL:
Verify the table count for any differences between the source and target database using these queries. If you find any differences, identify the root cause or take guidance from the AWS SCT logs and fix them accordingly before moving ahead.
Detailed information for each table
The previous SQL just verifies if all the tables present in the source database are migrated to the target database. However, it doesn’t ensure the integrity of the data types and other table definitions. The following query helps verify a few key features of the tables for the presence of LOB columns, computed columns, partitions, and column count. You can further enhance this query to add any other table definition as per your requirement.
Use the following SQL query for SAP ASE:
You can see the sample output in the following screenshot.
The following is a similar query for PostgreSQL:
You get the following output.
Verify the table details for any possible differences between the source and target database using these queries. If you find any differences, identify the root cause or take guidance from the AWS SCT logs and fix them accordingly.
Default Column Values
The following queries give you the details of Default Column Values for both the SAP ASE and PostgreSQL databases.
Use the following SQL query for SAP ASE:
You get the following output.
The following is a similar SQL query for PostgreSQL:
You get the following output.
Verify the default value details for any possible differences between the source and target database 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
The following queries give you the details of views for both the SAP ASE and PostgreSQL databases.
Use the following SQL query for SAP ASE:
You get the following output.
The following is a similar SQL query for PostgreSQL:
You get the following output.
You can also use the following alternate query for PostgreSQL:
Verify the results for differences in the view details with these queries. If you find any differences, identify the root cause or take guidance from the AWS SCT logs and fix them accordingly.
Functions
The following queries give you the details of functions for both the SAP ASE and PostgreSQL databases.
Use the following SQL query for SAP ASE:
The following screenshot shows the query output.
The following is a similar SQL query for PostgreSQL:
The following screenshot shows the query output.
Verify the function results for any possible differences between the source and target database 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
The following SQL queries gives the 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 similar SQL query for PostgreSQL:
The following screenshot shows the output.
Verify procedure information for any differences with these queries. If any are present, identify the root cause or take guidance from the AWS SCT logs and fix them accordingly.
Indexes
With the following queries, you can get the list of indexes and their types in both SAP ASE and PostgreSQL databases.
Primary keys are not included in the following SQL because we validate them in the constraints section.
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 PostgreSQL:
You get the following output.
The SAP ASE result has an extra column (IndexDescription
) categorizing the indexes as clustered or non-clustered, whereas the equivalent couldn’t be done in PostgreSQL because only non-clustered indexes get created. For this verification, the details up to the IndexType
column should suffice.
Note that in PostgreSQL, the index name needs to be unique across the database, so the names in the PostgreSQL output have different index names than SAP ASE because they had to be renamed.
Verify the index details for any possible differences between the source and target database 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
The following queries give you the details of triggers for both the SAP ASE and PostgreSQL databases.
Use the following SQL query for SAP ASE:
You get the following output.
The following is a similar SQL query for PostgreSQL:
You get the following output.
Verify the trigger details for any possible differences between the source and target database using these queries. If you find any differences, identify the root cause or take guidance from the AWS SCT logs and fix them accordingly.
Constraints
Constraints offer the advantages of defining integrity controls in one step during the table creation process 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 constraints
Use the following SQL query for SAP ASE:
You get the following output.
The following is a similar SQL query for PostgreSQL:
You get the following output.
Foreign key constraints
Use the following SQL query for SAP ASE:
You get the following output.
The following is a similar SQL query for PostgreSQL:
You get the following output.
Check constraints
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 SQL query for PostgreSQL:
You get the following output.
Conclusion
In this post, we walked through validation of different database objects after migration from SAP ASE 15.7+ to PostgreSQL. You can use this post as a reference guide to perform object validation while migrating from an SAP ASE database to a PostgreSQL database.
If you have any comments or questions, leave them in the comments section.
About the Author
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 homogeneous and heterogeneous database migrations and optimization in AWS cloud.
Nishad Mankar is a Database Consultant with AWS Professional Services. He helps customers to migrate and modernize their databases on AWS Cloud.
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.