Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TV3cF-0005gt-Ul for pgsql-docs@postgresql.org; Sun, 04 Nov 2012 17:04:08 +0000 Received: from mail-da0-f46.google.com ([209.85.210.46]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TV3cD-0002WC-2M for pgsql-docs@postgresql.org; Sun, 04 Nov 2012 17:04:07 +0000 Received: by mail-da0-f46.google.com with SMTP id n41so2343111dak.19 for ; Sun, 04 Nov 2012 09:04:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:subject:from:to:cc:date:in-reply-to:references :organization:content-type:x-mailer:content-transfer-encoding :mime-version:x-gm-message-state; bh=5bPMnJbHBHAMpOj08sOS6xGHsY4nLx27woVhRCrQdB8=; b=OAa2AWwvC49wmedKOOFTqEO8DqyqcIh691UYJ9LaOsbnXqagyZzG2hcPj7/sx496tk 4Ki8O2b6u72NxQRe1RO3sG8ZVxBaql0LTbhxFNXej6JwuQq0DfROPMsbFCi5/XeNQadZ /8ynD7dtXwo6LTEKuu2z2lBKeJuzpNPmjNCuk/f1RbXGV4QqqOuAFVFDDSTtmBrmplu2 irfgiIznPcip5cvh2c7lWX4KKiMs5uXPJRPsxde3hQIxJqN12wKHfcQ4NgFrhhmK+zJw Dqyyhi6s2PW88HN8g+L2KJQ46N9fx/ar2rrTyY03lScrsKEEzpteHNqmnkXZnEBHkgUG tzOg== Received: by 10.68.232.2 with SMTP id tk2mr23769257pbc.92.1352048642681; Sun, 04 Nov 2012 09:04:02 -0800 (PST) Received: from [192.168.1.102] (c-69-181-249-16.hsd1.ca.comcast.net. [69.181.249.16]) by mx.google.com with ESMTPS id v2sm7459905paz.27.2012.11.04.09.04.01 (version=SSLv3 cipher=OTHER); Sun, 04 Nov 2012 09:04:02 -0800 (PST) Message-ID: <1352048640.6292.1.camel@jdavis-laptop> Subject: Re: CONSTRAINT on ARRAY ELEMENTS From: Jeff Davis To: Nikolaos Ikonomopoulos Cc: pgsql-docs@postgresql.org Date: Sun, 04 Nov 2012 09:04:00 -0800 In-Reply-To: References: Organization: Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit Mime-Version: 1.0 X-Gm-Message-State: ALoCoQnfGBecswWVmHykv3VM3IEYTwRgJ283IEG2ZIwCrYA2ntOVgERC3KILBJ1R/IeotyDGdBU6 X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201211/4 X-Sequence-Number: 7496 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