Setting up Field constraints

Поиск
Список
Период
Сортировка
От Joseph Maxwell
Тема Setting up Field constraints
Дата
Msg-id 3C86AB7D.104CD2BE@jaymax.com
обсуждение исходный текст
Ответы Re: Setting up Field constraints
Re: Setting up Field constraints
Список pgsql-general
Hello,
I have created a DB and TABLE but would like to constrain one field to
accept either "YES" or "NO" only. How can I set this up?
I have tried various syntactic constructs of

     Prior_Rx   varchar(3) NULL CHECK ('Yes', 'No'),
     Prior_Rx   varchar(3) NULL CHECK (VALUE 'Yes', 'No'),
     Prior_Rx   varchar(3) NULL CHECK ('Yes', 'No'),
     Prior_Rx   varchar(3) NULL CONSTRAINT (CHECK (VALUE 'Yes', 'No')),
     Prior_Rx   varchar(3) NULL CONSTRAINT (CHECK ('Yes', 'No')),
     Prior_Rx   varchar(3) NULL CONSTRAINT (CHECK (VALUE Yes, No)),
     Prior_Rx   varchar(3) NULL CONSTRAINT (CHECK (Yes, No)),
     Prior_Rx   varchar(3) NULL CONSTRAINT (CHECK (Yes OR No)),
     Prior_Rx   varchar(3) NULL CHECK (Yes OR No),
     Prior_Rx   varchar(3) NULL CHECK ('Yes' OR 'No'),

Obviously they were all wrong, could someone advise?
Thanks

--  Joe  --
---------------------------------------------------------------------------------------
PS:
Just learned that the datatype should be 'bool' in this case

     haven't tested it yet

But had I wanted to restrict it to say either mike or john, or even one
of a list say, 'tea', 'coffee', 'chocolate' or 'espresso', how should
that be constructed?

В списке pgsql-general по дате отправления:

Предыдущее
От: "Gaston Micheri"
Дата:
Сообщение: Odbc, postgresql and disconnected recordsets
Следующее
От: Darren Ferguson
Дата:
Сообщение: Re: Have problems with 7.1 -> 7.2 upgrade