Re: Table definitions using CHECK and DEFAULT - Mailing list pgsql-general

From Command Prompt, Inc.
Subject Re: Table definitions using CHECK and DEFAULT
Date
Msg-id Pine.LNX.4.30.0111041618240.19169-100000@commandprompt.com
Whole thread Raw
In response to Table definitions using CHECK and DEFAULT  ("Matthew L. Wirges" <wirges@cerias.purdue.edu>)
List 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@commandprompt.com


pgsql-general by date:

Previous
From: "Said Badrul Nahar"
Date:
Subject: newbie question
Next
From: "Dr. Evil"
Date:
Subject: Re: newbie question