What you should know about constraints in PostgreSQL 18
Session Abstract
This talk explains how constraints work in Postgres by exploring the pg_constraint catalog and core concepts like table vs. column constraints, constraint triggers, domains and constraint deferrability through SQL queries. It then covers what’s new in Postgres 18 including temporal keys, NOT NULL as a first-class constraint, NOT ENFORCED and more.
Session Description
PostgreSQL 18 introduces significant enhancements to constraints, the first line of defense for maintaining data integrity. This talk focuses on new capabilities in version 18, including non-overlapping PRIMARY KEY, UNIQUE, and foreign key constraints; NOT NULL constraints becoming first-class citizens; the introduction of NOT ENFORCED constraints and improved support for partitioned tables. We’ll look at what’s new, why it matters and how to apply these features in real-world systems.
We’ll begin with a detailed walkthrough of the pg_constraint catalog, covering less commonly discussed concepts such as constraint deferrability, constraint triggers, domains and related internals. From there, we’ll move on to what’s new in PostgreSQL 18. A major addition is temporal keys, bringing PostgreSQL a step closer to supporting temporal data models. Another key change is NOT NULL becoming a standard constraint along with the implications of that promotion. We’ll also explore NOT ENFORCED constraints and other recent additions and briefly look ahead to what’s coming in PostgreSQL 19.