Re: How to restrict

From: Achilleas Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>
To: pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: Re: How to restrict
Date: 2019-02-26 15:18:21
Message-ID: 11341ee7-23e6-adfb-b14f-218eeffa8102@matrix.gatewaynet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 <https://directory.illinois.edu/person/lance>*
>
> /Software Architect/
>
> Web Services <https://webtools.illinois.edu/>
>
> Public Affairs <https://publicaffairs.illinois.edu/>
>
> Contact the Webtools Team <https://go.illinois.edu/contactUs>
>
> 217.333.0382
>
> lance(at)illinois(dot)edu <mailto:lance(at)illinois(dot)edu>
>
> /var/folders/wp/1f6l7hw95y718z976kgnl5f9kr5rtc/T/com.microsoft.Outlook/WebArchiveCopyPasteTempFiles/signature_logo.png <http://illinois.edu/>
>
> /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

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message gilberto.castillo 2019-02-26 15:19:53 Re: [MASSMAIL]Re: pg_dumpall: could not connect to database: FATAL
Previous Message Campbell, Lance 2019-02-26 15:11:32 How to restrict