Lists: | pgsql-sql |
---|
From: | Keith Gray <keith(at)heart(dot)com(dot)au> |
---|---|
To: | SQL <pgsql-sql(at)postgresql(dot)org> |
Subject: | Migrating a MySQL schema with an enum |
Date: | 2002-03-20 23:41:30 |
Message-ID: | 3C991E29.C90559F4@heart.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-sql |
SQL gurus,
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.
--
Keith Gray
Technical Development Manager
Heart Consulting Services P/L
mailto:keith(at)heart(dot)com(dot)au
From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | 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-20 23:53:55 |
Message-ID: | 200203202353.g2KNrtM11253@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-sql |
Keith Gray wrote:
> SQL gurus,
>
> 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.
You can use another table, or use CHECK constraints to limit the
possible values.
--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
From: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
---|---|
To: | 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 00:02:21 |
Message-ID: | Pine.LNX.4.30.0203201900010.812-100000@peter.localdomain |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
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(at)gmx(dot)net
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 |
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
From: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
---|---|
To: | Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au> |
Cc: | Keith Gray <keith(at)heart(dot)com(dot)au>, SQL <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Migrating a MySQL schema with an enum |
Date: | 2002-03-21 04:50:48 |
Message-ID: | Pine.LNX.4.30.0203202350070.812-100000@peter.localdomain |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-sql |
Christopher Kings-Lynne writes:
> > 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.
That's not an enumeration type, that's a set. For set's you create a
separate table.
--
Peter Eisentraut peter_e(at)gmx(dot)net
From: | Martín Marqués <martin(at)bugs(dot)unl(dot)edu(dot)ar> |
---|---|
To: | SQL <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Migrating a MySQL schema with an enum |
Date: | 2002-03-21 11:31:44 |
Message-ID: | 20020321113145.E84DBFA1D@bugs.unl.edu.ar |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-sql |
On Mié 20 Mar 2002 20:41, you wrote:
> SQL gurus,
>
> 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.
I had to migrate a DB from MySQL to PostgreSQL that had some enum as field
data type (I can't believe that something like that exists), and because it
was something like:
enum('s','n')
I changed it for:
col1 CHAR CHECK (col1 IN ('s','n'))
Which is SQL. :-)
If what is enumerated are numbres, just use INT instead of CHAR.
Saludos... :-)
--
Porqué usar una base de datos relacional cualquiera,
si podés usar PostgreSQL?
-----------------------------------------------------------------
Martín Marqués | mmarques(at)unl(dot)edu(dot)ar
Programador, Administrador, DBA | Centro de Telematica
Universidad Nacional
del Litoral
-----------------------------------------------------------------
From: | Martín Marqués <martin(at)bugs(dot)unl(dot)edu(dot)ar> |
---|---|
To: | "SQL" <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Migrating a MySQL schema with an enum |
Date: | 2002-03-21 11:43:40 |
Message-ID: | 20020321114341.6FD67FA1D@bugs.unl.edu.ar |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-sql |
On Mié 20 Mar 2002 23:31, you wrote:
> > 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.
That's not how enum() works.
--
Porqué usar una base de datos relacional cualquiera,
si podés usar PostgreSQL?
-----------------------------------------------------------------
Martín Marqués | mmarques(at)unl(dot)edu(dot)ar
Programador, Administrador, DBA | Centro de Telematica
Universidad Nacional
del Litoral
-----------------------------------------------------------------
From: | "Johny Jugianto" <johny(dot)q(at)rocketmail(dot)com> |
---|---|
To: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | [OOT] timestamp / time ('now') in postgresql 7.2? |
Date: | 2002-03-21 11:46:50 |
Message-ID: | 000a01c1d0ce$178929b0$050000c0@enterprise |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-sql |
hi
i'm have installed latest version of postgresql which is 7.2
why i can not use timestamp('now') or time('now') ?
it said : ERROR: parser: parse error at or near "'"
can anyone explain why?
i'm try in 7.1.x. it's works well
did i miss something when installation? is it in new version need somekind
of "plug-in"?
ps: date('now') is work fine
thx in advance
From: | Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au> |
---|---|
To: | Johny Jugianto <johny(dot)q(at)rocketmail(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: [OOT] timestamp / time ('now') in postgresql 7.2? |
Date: | 2002-03-21 14:29:39 |
Message-ID: | 20020321222743.V96955-100000@houston.familyhealth.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-sql |
> i'm have installed latest version of postgresql which is 7.2
> why i can not use timestamp('now') or time('now') ?
> it said : ERROR: parser: parse error at or near "'"
Those two words have become a little more reserved. If you go
"timestamp"('now') or "time"('now') it should work.
Even better, I think you can go timestamp 'now' or time 'now' instead
IIRC.
Chris
From: | Vincent Stoessel <vincent(at)xaymaca(dot)com> |
---|---|
To: | Martín Marqués <martin(at)bugs(dot)unl(dot)edu(dot)ar> |
Cc: | SQL <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Migrating a MySQL schema with an enum |
Date: | 2002-03-21 14:40:42 |
Message-ID: | 3C99F0EA.2050206@xaymaca.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-sql |
Martín Marqués wrote:
> On Mié 20 Mar 2002 20:41, you wrote:
>
>>SQL gurus,
>>
>>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.
>
>
> I had to migrate a DB from MySQL to PostgreSQL that had some enum as field
> data type (I can't believe that something like that exists)
<snip>
another shot at the mysql db.
Please don't forget that PG also has non standard data types
available.
Vinny
From: | "Ross J(dot) Reedstrom" <reedstrm(at)rice(dot)edu> |
---|---|
To: | Mart?n Marqu?s <martin(at)bugs(dot)unl(dot)edu(dot)ar>, Vincent Stoessel <vincent(at)xaymaca(dot)com> |
Cc: | SQL <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Migrating a MySQL schema with an enum |
Date: | 2002-03-21 16:02:28 |
Message-ID: | 20020321160227.GC9471@rice.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-sql |
On Thu, Mar 21, 2002 at 09:40:42AM -0500, Vincent Stoessel wrote:
> Mart?n Marqu?s wrote:
> >On Mi? 20 Mar 2002 20:41, you wrote:
> >
> >>SQL gurus,
> >>
> >>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.
> >
> >
> >I had to migrate a DB from MySQL to PostgreSQL that had some enum as field
> >data type (I can't believe that something like that exists)
>
> <snip>
>
> another shot at the mysql db.
> Please don't forget that PG also has non standard data types
> available.
Your pique at seeing what you took as an unfair shot at another db caused you
to be blinded to what Martin was pointing out. In this case, MySQL has a
gratutiously non-standard feature: the equivalent CHECK constraint is only
a few more characters, and easier to read (IMHO)
Ross
From: | Martín Marqués <martin(at)bugs(dot)unl(dot)edu(dot)ar> |
---|---|
To: | "Ross J(dot) Reedstrom" <reedstrm(at)rice(dot)edu>, Vincent Stoessel <vincent(at)xaymaca(dot)com> |
Cc: | SQL <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Migrating a MySQL schema with an enum |
Date: | 2002-03-22 11:18:23 |
Message-ID: | 20020322111827.8D684FA1D@bugs.unl.edu.ar |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-sql |
On Jue 21 Mar 2002 13:02, Ross J. Reedstrom wrote:
> On Thu, Mar 21, 2002 at 09:40:42AM -0500, Vincent Stoessel wrote:
> > Mart?n Marqu?s wrote:
> > >On Mi? 20 Mar 2002 20:41, you wrote:
> > >>SQL gurus,
> > >>
> > >>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.
> > >
> > >I had to migrate a DB from MySQL to PostgreSQL that had some enum as
> > > field data type (I can't believe that something like that exists)
> >
> > <snip>
> >
> > another shot at the mysql db.
> > Please don't forget that PG also has non standard data types
> > available.
>
> Your pique at seeing what you took as an unfair shot at another db caused
> you to be blinded to what Martin was pointing out. In this case, MySQL has
> a gratutiously non-standard feature: the equivalent CHECK constraint is
> only a few more characters, and easier to read (IMHO)
Thanks Ross, I was just about to say the same thing. Why had an unstandard
data type, whn you can have it SQL-standard.
I think that the problem MySQL has is CHECK.
Saludos... :-)
--
Porqué usar una base de datos relacional cualquiera,
si podés usar PostgreSQL?
-----------------------------------------------------------------
Martín Marqués | mmarques(at)unl(dot)edu(dot)ar
Programador, Administrador, DBA | Centro de Telematica
Universidad Nacional
del Litoral
-----------------------------------------------------------------