Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-sql by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group