Re: How to restrict

Поиск
Список
Период
Сортировка
От Achilleas Mantzios
Тема Re: How to restrict
Дата
Msg-id 11341ee7-23e6-adfb-b14f-218eeffa8102@matrix.gatewaynet.com
обсуждение исходный текст
Ответ на How to restrict  ("Campbell, Lance" <lance@illinois.edu>)
Список pgsql-admin
On 26/2/19 5:11 μ.μ., Campbell, Lance wrote:

PostgreSQL 10.x

 

What is the best way to restrict the values on a text field to make sure they only contain particular values:  Example:  The field “type” can only contain the values of “X”, “Y” and “Z”.  Would a trigger be the best strategy?  Or is there a special SQL type I should use in this particular case? 

Easy with a CHECK CONSTRAINT, like :
create table baba (type varchar(10) CHECK (type in ('X','Y','Z')));

 

Thanks,

 

LANCE CAMPBELL

Software Architect

 

Web Services

Public Affairs

Contact the Webtools Team

217.333.0382

lance@illinois.edu

 

 

/var/folders/wp/1f6l7hw95y718z976kgnl5f9kr5rtc/T/com.microsoft.Outlook/WebArchiveCopyPasteTempFiles/signature_logo.png

 

Under the Illinois Freedom of Information Act any written communication to or from university employees regarding university business is a public record and may be subject to public disclosure.

 



-- 
Achilleas Mantzios
IT DEV Lead
IT DEPT
Dynacom Tankers Mgmt
Вложения

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

Предыдущее
От: "Campbell, Lance"
Дата:
Сообщение: How to restrict
Следующее
От: gilberto.castillo@etecsa.cu
Дата:
Сообщение: Re: [MASSMAIL]Re: pg_dumpall: could not connect to database: FATAL