From: | "Robert B(dot) Easter" <reaster(at)comptechnews(dot)com> |
---|---|
To: | Tom Cook <tcook(at)lisa(dot)com(dot)au>, Peter Eisentraut <peter_e(at)gmx(dot)net> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Enumerated data type |
Date: | 2000-05-03 02:03:33 |
Message-ID: | 00050222085704.00670@comptechnews |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, 02 May 2000, Tom Cook wrote:
> On Tue, 2 May 2000, Peter Eisentraut wrote:
>
> > Anand Raman writes:
> >
> > > Is there anything equivalent to the enumerated data types in
> > > postgresql..
> >
> > You might find that strings with check constraints will do the job, e.g.
> >
> > create table my_tbl (
> > ...
> > color text check color in ('blue', 'green', 'white'),
> > ...
> > );
> >
>
> For anything much more than this, I'd just create a table with all the
> possible values in it, each with a unique identifier, and then use the
> identifier in my_tbl. Then you can control the possible values more
> easily.
>
> --
> Tom Cook - Software Engineer
Yup, you could create a special table that contains a column of the allowed
values and make it with a primary key. In your table where you want the enum,
make that column REFERENCES the special table you setup. That will constrain
it to only allow values of the primary key.
From | Date | Subject | |
---|---|---|---|
Next Message | Robert B. Easter | 2000-05-03 02:51:55 | Re: OID output problems |
Previous Message | Robert B. Easter | 2000-05-03 01:27:26 | Re: OID output problems |