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: (view raw, whole thread or download thread mbox)
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 

  Richard Huxton
  Archonet Ltd

In response to


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-2017 The PostgreSQL Global Development Group