Re: changing constraints - Mailing list pgsql-sql

From Richard Huxton
Subject Re: changing constraints
Date
Msg-id 200403101351.51800.dev@archonet.com
Whole thread Raw
In response to changing constraints  ("David" <de4@kent.ac.uk>)
List pgsql-sql
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


pgsql-sql by date:

Previous
From: Achilleus Mantzios
Date:
Subject: Re: changing constraints
Next
From: "David"
Date:
Subject: Re: changing constraints