Migrate rows with unique constraints to Amazon RDS for PostgreSQL or Amazon Aurora PostgreSQL
Database Blog
This article discusses how to handle unique constraints when migrating rows with unique constraints to Amazon RDS for PostgreSQL or Amazon Aurora PostgreSQL. It explains the different behaviors of handling null values in unique constraints across various databases like Oracle, SQL Server, IBM Db2, and PostgreSQL.
Specifically, the article covers:
- How unique keys work in PostgreSQL
- How null values are handled in unique keys in Oracle, SQL Server, IBM Db2, and PostgreSQL
- Solutions to mimic the source database behavior for handling null values in unique constraints when migrating to PostgreSQL:
- Using a function-based unique index
- Using an array-based unique index
- Using a unique index with a case structure
- Using the NULLS NOT DISTINCT clause (PostgreSQL 15+)
- A comparison summary of the solutions and the PostgreSQL versions they are supported in
The AWS News Feed is currently looking for gold sponsors. If you want to support the AWS community and reach a large audience of AWS professionals, consider sponsoring the AWS News Feed.
Related articles
Oct 28
2025
2025
Migrate Oracle reference partitioned tables to Amazon RDS or Aurora PostgreSQL with AWS DMS
May 12
2026
2026
Migrating Amazon RDS for PostgreSQL to Amazon Aurora using seeded logical replication
Jun 4
2025
2025
Migrate Google Cloud SQL for PostgreSQL to Amazon RDS and Amazon Aurora using pglogical
Jul 1
2024
2024
AWS DMS homogenous migration from PostgreSQL to Amazon Aurora PostgreSQL
The AWS News Feed is currently looking for silver sponsors. If you want to support the AWS community and reach a large audience of AWS professionals, consider sponsoring the AWS News Feed.