Re: Migrating a MySQL schema with an enum

From: "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>
To: "Peter Eisentraut" <peter_e(at)gmx(dot)net>, "Keith Gray" <keith(at)heart(dot)com(dot)au>
Cc: "SQL" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Migrating a MySQL schema with an enum
Date: 2002-03-21 02:31:12
Message-ID: GNELIHDDFBOCMGBFGEFOAENACBAA.chriskl@familyhealth.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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')),
> ...
> );

Nope - cos you need 'blue,green' as a value, etc. as well.

I use a varbit field and do the translations from an array of strings to a
bitset and vice versa in the app layer.

Chris

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2002-03-21 04:42:25 Re: delete -> copy in -> WAL problem..?
Previous Message Peter Eisentraut 2002-03-21 00:02:21 Re: Migrating a MySQL schema with an enum