Thread: ENUM Type

ENUM Type

From
Kyle Bateman
Date:
Does PostgreSQL have support for an ENUM type?

I didn't see it in the docs, but maybe someone has figured out how to
create one easily with the add new type stuff...

Kyle


Attachment

Re: [SQL] ENUM Type

From
Peter Eisentraut
Date:
Kyle Bateman writes:

> Does PostgreSQL have support for an ENUM type?

No. You can create a separate table that maps some, say integer, key to a,
say, string. That's usually how ENUM stuff is ported away from MySQL (also
known as TheirSQL). Alternatively you can also pull something like this:

CREATE TABLE test (   ...   a text check (a in ('value1', 'value2', ...)),   ...
)

You get the idea.

> I didn't see it in the docs, but maybe someone has figured out how to
> create one easily with the add new type stuff...

That "add new type stuff" isn't all one might think it is either.

-- 
Peter Eisentraut                  Sernanders väg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden