enum data type
can somebody point me in the direction of info on how to implement an
'enum' data type?
trav
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
Hi,
you can use the check.
create table language (
lang_id SERIAL primary key,
shortcut char(2) not null unique check (shortcut in
('en','nl','de'))
);
CoL
travis wrote:
Show quoted text
can somebody point me in the direction of info on how to implement an
'enum' data type?trav
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
Postgres doesn't explicitly, but you can make one yourself:
CREATE TABLE enum ( id SERIAL PRIMARY KEY, data VARCHAR(10) );
CREATE TABLE test (
field INT REFERENCES enum
);
You could have a rule or trigger for "test" that converts the textual
representation to it's numeric id on insert if you want the added
convenience.
Keary Suska
Esoteritech, Inc.
"Leveraging Open Source for a better Internet"
Show quoted text
From: travis <smitht@cache.net>
Organization: Newsfeeds.com http://www.newsfeeds.com 80,000+ UNCENSORED
Newsgroups.
Date: Fri, 28 Sep 2001 15:00:59 -0600
To: pgsql-general@postgresql.org
Subject: [GENERAL] enum data typecan somebody point me in the direction of info on how to implement an
'enum' data type?trav
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =--------------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org