Re: changing constraints

From: Richard Huxton <dev(at)archonet(dot)com>
To: "David" <de4(at)kent(dot)ac(dot)uk>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: changing constraints
Date: 2004-03-10 13:51:51
Message-ID: 200403101351.51800.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Jander Rebelo Luiz 2004-03-10 14:29:58 Break a Report in Run Time
Previous Message Achilleus Mantzios 2004-03-10 13:41:20 Re: changing constraints