Re: Poor-man's enumeration type

Поиск
Список
Период
Сортировка
Искать
От
Michael Glaesemann
Тема
Re: Poor-man's enumeration type
Дата
Msg-id
beac9cea3a272b965cd0925b4f7f080d@myrealbox.com
Ответ на
Poor-man's enumeration type (Keith Worthington)
Список
Дерево обсуждения
Poor-man's enumeration type Keith Worthington <KeithW@NarrowPathInc.com>
Re: Poor-man's enumeration type Bruce Momjian <pgman@candle.pha.pa.us>
Re: Poor-man's enumeration type Michael Glaesemann <grzm@myrealbox.com>
Re: Poor-man's enumeration type Tom Lane <tgl@sss.pgh.pa.us>
Re: Poor-man's enumeration type "Keith Worthington" <keithw@narrowpathinc.com>
Re: Poor-man's enumeration type Tom Lane <tgl@sss.pgh.pa.us>
Re: Poor-man's enumeration type Bruce Momjian <pgman@candle.pha.pa.us>

On Apr 26, 2005, at 11:52, Keith Worthington wrote:

>    The type "char" (note the quotes) is different
>    from char(1)in that it only uses one byte of
>    storage. It is internally used in the system
>    catalogs as a poor-man's enumeration type.
>
> Is this a SQL standard data type?

No.

> Can I expect this type to be supported in PostgreSQL 'forever'?

I'm not in a position to say, but I do know that "It is internally used 
in the system catalogs" and the system catalogs carry with them the 
explicit warning that they may change--and have changed in the 
past--between releases.

In general, enumeration can be handled by setting up a small table that 
lists allowed values. e.g. (untested),

create table colors ( color text not null unique );

create table houses (
	house_id serial not null unique
	, house_color text not null
	references colors (color) on update cascade on delete cascade
);

Hope this helps.

Michael Glaesemann
grzm myrealbox com

В списке pgsql-novice по дате отправления
От: Bruce Momjian
Дата:
От: Tom Lane
Дата:
FAQ