From: | "Matthew L(dot) Wirges" <wirges(at)cerias(dot)purdue(dot)edu> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Table definitions using CHECK and DEFAULT |
Date: | 2001-11-04 23:40:58 |
Message-ID: | 20011104184058.B8831@basm.cerias.purdue.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I am adding PostgreSQL support to some software that I've been
developing and I've hit a few snags.
I've found that MySQL's "ENUM" can be emulated with PostgreSQL's
"CHECK". Unfortunately it appears that I cannot use both the DEFAULT
modifier and the check modifier at the same time.
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
If I write the definition without DEFAULT it works fine, if I write it
without the CHECK statement it works fine too..
(I've also split up the column definition and the check definition, i.e.
address_type VARCHAR(30) DEFAULT 'unknown' NOT NULL,
CHECK(address_type IN ("unknown", "forged", "proxy", "temporary", "permanent"))
)
Is the SQL wrong? Is it just not possible to do this? Or is this a
possible bug?
Any help is appreciated!
--
Matthew Wirges
Developer::CERIAS Incident Response Database
https://cirdb.cerias.purdue.edu/
wirges(at)cerias(dot)purdue(dot)edu
From | Date | Subject | |
---|---|---|---|
Next Message | Command Prompt, Inc. | 2001-11-05 00:20:36 | Re: Table definitions using CHECK and DEFAULT |
Previous Message | Jeff Lu | 2001-11-04 23:35:59 | Is there an internal timestamp on a table when it was created? |