Re: enumerated type..

From: Michael Kleiser <mkl(at)webde-ag(dot)de>
To: raptor(at)tvskat(dot)net
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: enumerated type..
Date: 2004-07-19 14:46:08
Message-ID: 40FBDEB0.2020405@webde-ag.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I don`t know, if there is a special feature in postgresql for this.
The standard SQL-way is to create a lookup-table and define a foreign-key to it.

create table states( state_id int primary key not null
, state_text varchar(30) not null
, constraint uk_states_state_text unique( state_text ) );

create table states( state_id int primary key not null , state_text varchar(30) not null );
alter table states add constraint uk_states_state_text unique( state_text );

create table your_table (
...
state_id int not null
, constraint fk_yt_state_id foreign key (state_id) references states
);

raptor(at)tvskat(dot)net schrieb:
> hi,
>
> Is it possible in Postgre to have enum type, so that later table fileld get values from 1-6 (saving space)
>
> 1 - statex
> 2 - stateY
> 3 - stateZ
>
> something like that and then constrain on this enum type..
>
> tia
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2004-07-19 14:51:04 Re: Index Using
Previous Message Damon Hart 2004-07-19 14:17:09 special table queries slow until dump/restore