Re: Table definitions using CHECK and DEFAULT

From: "Command Prompt, Inc(dot)" <pgsql-general(at)commandprompt(dot)com>
To: "Matthew L(dot) Wirges" <wirges(at)cerias(dot)purdue(dot)edu>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Table definitions using CHECK and DEFAULT
Date: 2001-11-05 00:20:36
Message-ID: Pine.LNX.4.30.0111041618240.19169-100000@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, 4 Nov 2001, Matthew L. Wirges wrote:
>This line:
>address_type VARCHAR(30) DEFAULT 'unknown' NOT NULL CHECK(address_type
>IN ("unknown", "forged", "proxy", "temporary", "permanent"))
>gives the error:
>psql:IRDB_POSTGRES:69: ERROR: Attribute 'unknown' not found
[snip]
>Is the SQL wrong? Is it just not possible to do this? Or is this a
>possible bug?

No, the problem is that you're specifying string constants with
double-quotes, not single-quotes. ;) Double-quotes are for identifiers,
not constants.

Change it to read like this, and you'll be set:

address_type VARCHAR(30)
DEFAULT 'unknown'
NOT NULL
CHECK(address_type IN
('unknown', 'forged', 'proxy', 'temporary', 'permanent'))

Regards,
Jw.
--
by way of pgsql-general(at)commandprompt(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Said Badrul Nahar 2001-11-05 00:25:19 newbie question
Previous Message Matthew L. Wirges 2001-11-04 23:40:58 Table definitions using CHECK and DEFAULT