Re: Migrating a MySQL schema with an enum

Поиск
Список
Период
Сортировка
От Christopher Kings-Lynne
Тема Re: Migrating a MySQL schema with an enum
Дата
Msg-id GNELIHDDFBOCMGBFGEFOAENACBAA.chriskl@familyhealth.com.au
обсуждение исходный текст
Ответ на Re: Migrating a MySQL schema with an enum  (Peter Eisentraut <peter_e@gmx.net>)
Ответы Re: Migrating a MySQL schema with an enum  (Peter Eisentraut <peter_e@gmx.net>)
Re: Migrating a MySQL schema with an enum  (Martín Marqués <martin@bugs.unl.edu.ar>)
Список 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



В списке pgsql-sql по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: Migrating a MySQL schema with an enum
Следующее
От: Tom Lane
Дата:
Сообщение: Re: delete -> copy in -> WAL problem..?