Re: enum

From: Rod Kreisler <rod(at)23net(dot)net>
To: "Adler, Stephen" <adler(at)bnl(dot)gov>, pgsql-novice(at)postgresql(dot)org
Subject: Re: enum
Date: 2002-11-30 17:57:03
Message-ID: JNEGKNDJGBKLBDGPOPFOKEBKDFAA.rod@23net.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Define the constraint table:

create table "myConstraints"
(
"myConstraint" varchar(32) not null primary key
)

in the referencing table declare the constrained column:

"constraintColumn" varchar(32) not null references "myConstraints" on
update cascade,

Of course the size of the varchar is up to you, but should be the same in
both tables. The "on update cascade" allows you to change the value of the
"myConstraint" column in "myConstraints" and have it update the values for
those matching entries in the "constraintColumn" in the referencing table.

HTH

Rod

> -----Original Message-----
> From: pgsql-novice-owner(at)postgresql(dot)org
> [mailto:pgsql-novice-owner(at)postgresql(dot)org]On Behalf Of Adler, Stephen
> Sent: Saturday, November 30, 2002 12:49 PM
> To: pgsql-novice(at)postgresql(dot)org
> Subject: Re: [NOVICE] enum
>
>
> In replying to my own post, I realize that a mysql enum is
> equal to a varchar with a constraint on the value of the
> string inserted into the column, (which is what I want to do,
> make sure only 2 or 3 different strings can stored in
> the varchar column.) But I'm having a hard time finding
> the syntax for the column constraint entry in the create
> table command. anyone can let me know where I can find info
> on the constraint syntax? I've looked through the postgresql
> manuals and haven't found anything.
>
> Thanks again. Steve.
>
> On Sat, 2002-11-30 at 12:13, Adler, Stephen wrote:
> > As you guys can see, I'm in the process of migrating from mysql to
> > postgres. My next question to you guys is how does one implement
> > the mysql enum type. Also, when I issue the \dT command, I get
> > this nice list of data types. Are all those data types standard
> > SQL data types? or are some postgres "extensions"?
> >
> > Cheers. Steve.

In response to

  • Re: enum at 2002-11-30 17:48:39 from Adler, Stephen

Responses

  • Re: enum at 2002-11-30 18:17:25 from Adler, Stephen

Browse pgsql-novice by date

  From Date Subject
Next Message Adler, Stephen 2002-11-30 18:17:25 Re: enum
Previous Message Tom Lane 2002-11-30 17:49:44 Re: switching databases