Re: CONSTRAINT on ARRAY ELEMENTS - Mailing list pgsql-docs

From Jeff Davis
Subject Re: CONSTRAINT on ARRAY ELEMENTS
Date
Msg-id 1352048640.6292.1.camel@jdavis-laptop
Whole thread Raw
In response to CONSTRAINT on ARRAY ELEMENTS  (Nikolaos Ikonomopoulos <ikonomn@hotmail.com>)
Responses Re: CONSTRAINT on ARRAY ELEMENTS
List pgsql-docs
On Sat, 2012-11-03 at 09:43 +0000, Nikolaos Ikonomopoulos wrote:
>
> CREATE TABLE employ_presence
> (
>   p_id character(6) not null,
>   p_month character(3) NOT NULL,
>   statuscode integer array[7],
>   CONSTRAINT unq_employ_presence UNIQUE (p_id, p_month),
>   CONSTRAINT chk_employ_month CHECK (p_month = ANY
> (ARRAY['Jan'::bpchar, 'Feb'::bpchar, 'Mar'::bpchar, 'Apr'::bpchar,
> 'May'::bpchar, 'Jun'::bpchar, 'Jul'::bpchar, 'Aug'::bpchar,
> 'Sep'::bpchar, 'Oct'::bpchar, 'Nov'::bpchar, 'Dec'::bpchar]))
> );
>
>
>
> How can add a CONSTRAINT on statuscode array elements to accept values
> between 0 to 5

You can try:

   CHECK (statuscode <@ ARRAY[1,2,3,4,5])

Regards,
    Jeff Davis




pgsql-docs by date:

Previous
From: Dmitriy Igrishin
Date:
Subject: Re: CONSTRAINT on ARRAY ELEMENTS
Next
From: Nikolaos Oikonomopoulos
Date:
Subject: Re: CONSTRAINT on ARRAY ELEMENTS