Re: equivalent of mysql's SET type?

From: Darren Duncan <darren(at)darrenduncan(dot)net>
To: Reece Hart <reece(at)harts(dot)net>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: equivalent of mysql's SET type?
Date: 2011-03-09 01:52:33
Message-ID: 4D76DD61.7040707@darrenduncan.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Reece Hart wrote:
> I'm considering porting a MySQL database to PostgreSQL. That database uses
> MySQL's SET type. Does anyone have advice about representing this type in
> PostgreSQL?
>
> MySQL DDL excerpt:
> CREATE TABLE `transcript_variation` (
> `transcript_variation_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
> `transcript_stable_id` varchar(128) NOT NULL,
> ...
> `consequence_type`
> set('ESSENTIAL_SPLICE_SITE','STOP_GAINED','STOP_LOST','COMPLEX_INDEL','SPLICE_SITE')
> ) ENGINE=MyISAM AUTO_INCREMENT=174923212 DEFAULT CHARSET=latin1;
>
> I'm considering implementing this as a new type based on a bit vector, but I
> wonder if anyone has a more flexible general solution.

Try starting with an enum type to define the possible values:

CREATE TYPE Consequence_Type
AS ENUM ('ESSENTIAL_SPLICE_SITE','STOP_GAINED',
'STOP_LOST','COMPLEX_INDEL','SPLICE_SITE');

... and then you could try using "ARRAY OF Consequence_Type" or some such.

-- Darren Duncan

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Noah Misch 2011-03-09 03:43:55 Re: 9.1 - rewrite less alter table?
Previous Message Steve Atkins 2011-03-09 01:51:50 Re: equivalent of mysql's SET type?