Re: EVAL and SET equivalents in PostgreSQL
От | Bruce Momjian |
---|---|
Тема | Re: EVAL and SET equivalents in PostgreSQL |
Дата | |
Msg-id | 200207032021.g63KLZs02514@candle.pha.pa.us обсуждение исходный текст |
Ответ на | EVAL and SET equivalents in PostgreSQL (Lynn David Newton <lynn.newton@cox.net>) |
Ответы |
Re: EVAL and SET equivalents in PostgreSQL
|
Список | pgsql-general |
Sure, use CHECK constraints on the column. That is the ANSI standard way. gender CHAR(1) CHECK (gender IN ('M','F')), --------------------------------------------------------------------------- Lynn David Newton wrote: > > This is no doubt asked frequently, but I have exactly two days > experience with PostgreSQL, and am hot on a project for which I need a > more-or-less immediate answer. > > Most of my previous DB experience has been with MySQL, which supported > ENUM('value1','value2'...) data types, to allow a column to be > assigned the value of exactly one item from the list, and also the > SET('value1','value2',...) type to allow zero or more members of the > set of values. > > I need this functionality or something equivalent in a DB I'm setting > up on a project, and a half day of rumbling around in man pages and > printed documentation has yielded no obvious answer. I did learn about > creating arrays, but that's not exactly what I want. > > If I try to INSERT an illegel value for a SET or ENUM field, MySQL > will return an error message, which is what you want it to do. > > Without that, you have to add a layer of programming to intercept the > values that are coming in and verify that it's good stuff -- lots of > trouble that I'd like to avoid if possible. > > I'm asking this group because I know that surely I am not the first > migrant from MySQL to come up against this problem, and suspect the > answer is common knowledge that I have not yet groked. > > Many thanks for any insights shared. > > -- > Lynn David Newton > Phoenix, AZ > > > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/users-lounge/docs/faq.html > > > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
В списке pgsql-general по дате отправления: