From: Richard Huxton <dev@archonet.com>
To: David <de4@kent.ac.uk>
To: pgsql-sql@postgresql.org
Subject: Re: changing constraints
Date: Wed, 10 Mar 2004 13:51:51 +0000
Message-ID: <200403101351.51800.dev@archonet.com> (raw)
In-Reply-To: <008901c4069c$ba6591e0$49660c81@ad.kent.ac.uk>
References: <403F762B.20002@aol.net>
<20773.1077905537@sss.pgh.pa.us>
<008901c4069c$ba6591e0$49660c81@ad.kent.ac.uk>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: dev@archonet.com, de4@kent.ac.uk
Subject: Re: changing constraints
In-Reply-To: <200403101351.51800.dev@archonet.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox