X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id AAE4AD1B530 for ; Wed, 10 Mar 2004 13:51:55 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 83677-08 for ; Wed, 10 Mar 2004 09:51:55 -0400 (AST) Received: from anchor-post-37.mail.demon.net (anchor-post-36.mail.demon.net [194.217.242.86]) by svr1.postgresql.org (Postfix) with ESMTP id 6BB41D1B4B4 for ; Wed, 10 Mar 2004 09:51:51 -0400 (AST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-37.mail.demon.net with esmtp (Exim 3.35 #1) id 1B147m-0008uz-0b; Wed, 10 Mar 2004 13:51:54 +0000 Received: by mainbox.archonet.com (Postfix, from userid 529) id 4211B17216; Wed, 10 Mar 2004 13:51:54 +0000 (GMT) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 88D1516BF8; Wed, 10 Mar 2004 13:51:52 +0000 (GMT) From: Richard Huxton To: "David" , Subject: Re: changing constraints Date: Wed, 10 Mar 2004 13:51:51 +0000 User-Agent: KMail/1.5 References: <403F762B.20002@aol.net> <20773.1077905537@sss.pgh.pa.us> <008901c4069c$ba6591e0$49660c81@ad.kent.ac.uk> In-Reply-To: <008901c4069c$ba6591e0$49660c81@ad.kent.ac.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200403101351.51800.dev@archonet.com> X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200403/105 X-Sequence-Number: 17204 On Wednesday 10 March 2004 12:27, David wrote: > I tried adding a constraint thus: > de4=> ALTER TABLE genus ADD CHECK(gender = 'masculine' || 'feminine'); > But get the msg: > ERROR: AlterTableAddConstraint: rejected due to CHECK constraint $2 > I cant see a $2 constraint so why am i getting the error msg? Firstly, $2 will be the automatically created name for this new constraint. Secondly || doesn't mean OR - it joins strings. Try something like (untested): ALTER TABLE genus ADD CONSTRAINT valid_gender CHECK (gender IN ('masculine','feminine')); -- Richard Huxton Archonet Ltd