Implementing standard SQL's DOMAIN constraint

From: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Implementing standard SQL's DOMAIN constraint
Date: 2019-01-02 17:12:47
Message-ID: alpine.LNX.2.20.1901020905410.20959@salmo.appl-ecosys.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Happy New Year all,

My readings taught me that standard SQL has a domain constraint that checks
for the same valid characters in a column common to multiple tables.
Example:

CREATE DOMAIN state_code AS char(2)
DEFAULT '??'
CONSTRAINT valid_state_code
CHECK (value IN ('AL', 'AK', 'AZ', ...));

This applies to all tables each having a column named state_code.

I see the value of this feature when multiple tables have start_date and
end_date columns with a constraint that ensures the start_date is <= to the
end date.

Reading the release 10 manual I find many constraints and I want to learn
which one will implement this feature. A pointer is needed.

Rich

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2019-01-02 17:34:32 Re: Implementing standard SQL's DOMAIN constraint
Previous Message Tom Lane 2019-01-02 16:11:39 Re: Query planner / Analyse statistics bad estimate rows=1 with maximum statistics 10000 on PostgreSQL 10.2