On Mon, 2026-09-14 at 07:45 +0100, Eugene Losowski-Gallagher wrote:
> As far as I can tell:
> https://www.postgresql.org/docs/current/ddl-constraints.html
> Has nothing on a check array constraint, or an oracle example for previous
> "CHECK usage IN ('M', 'H', 'W', 'F')"
> I.e this is an enum of values:
>
> CHECK (usage = ANY
> (ARRAY['M'::character(1),'H'::character(1),'W'::character(1),'F'::character(1)]))
> NOT VALID
>
> Please can it be added into the documentation, or a URL given by return that
> contains it.
> I have been unable to find any in recent documentation. I am pretty sure it
> existed in old documentation, or I reverse engineered it from pgAdmin
> software.
> I would be very useful to have it documented properly.
>
> That URL above includes all the other value constraints (against comparator
> const, against comparator variable, unique and foreign key), but nothing for
> a fixed limited set of equals values.
>
> In the above example I provided it is needed as not all letters are valid.
> Another example would be "displayed = Y, N"
>
> Postgres is a little more finicky than oracle, but the feature exists, and
> works nicely, just with awkward syntax.
> All I am asking is the documentation to include it.
There is no special "check array constraint", so there is no point in
documenting it.
The following syntax works fine with PostgreSQL:
CHECK (usage IN ('M', 'H', 'W', 'F'))
True, your alternative spelling works just as well, but there is nothing
mysterious about it:
- <operator> ANY is documented in [1]
- the ARRAY[] constructor syntax is documented in [2]
- the proprietary type cast syntax using :: is documented in [3]
There is no special check constraint syntax in play that would need
additional documentation.
Yours,
Laurenz Albe
[1]:
https://www.postgresql.org/docs/current/functions-subquery.html#FUNCTIONS-SUBQUERY-ANY-SOME
[2]: https://www.postgresql.org/docs/current/arrays.html#ARRAYS-INPUT
[3]:
https://www.postgresql.org/docs/current/sql-expressions.html#SQL-SYNTAX-TYPE-CASTS