Re: Migrating a MySQL schema with an enum

Peter Eisentraut <peter_e@gmx.net>

From: Peter Eisentraut <peter_e@gmx.net>
To: Keith Gray <keith@heart.com.au>
Cc: SQL <pgsql-sql@postgresql.org>
Date: 2002-03-21T00:02:21Z
Lists: pgsql-sql
Keith Gray writes:

> Migrating a MySQL schema with an enum to PostgreSQL,
> is there an equivalent type or do I have to declare
> another table for "enum" values.

Generally, you'd use a text field with a check constraint.  For example:

CREATE TABLE car (
 ...
 color text check (color in ('blue', 'green', 'yellow')),
 ...
);

-- 
Peter Eisentraut   peter_e@gmx.net