Re: Robust ways for checking allowed values in a column

From: Rob Sargent <robjsargent(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Robust ways for checking allowed values in a column
Date: 2022-01-25 16:40:53
Message-ID: 7bcf6809-a959-5224-93db-645d15cd4359@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 1/25/22 09:35, Shaozhong SHI wrote:
> How about adding null as an alteration.
>
> Would this be robust?
>
> Regards,
>
> David
>
> On Tue, 25 Jan 2022 at 14:25, David G. Johnston
> <david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
>
> On Tue, Jan 25, 2022 at 6:56 AM Shaozhong SHI
> <shishaozhong(at)gmail(dot)com> wrote:
>
>  select form from mytable  where form ~
> '^Canal$|^Drain$|^Foreshore$|^inlandRiver$|^Lake$|^lockOrFlightOfLocks$|^Marsh$|^Researvoir$|^Sea$|^tidalRiver$|^Transfer$'
>
>
> You do not need to repeat the boundary metacharacters on each
> branch.  You can assert their presence just once and then use
> parentheses to group the alternations.
>
> form ~ '^(?Canal|Drain|etc...)$'
>
> David J.
>

You would need to add form ~ 'expression' or form is null

And a body of held water is a reservoir (no 'a')

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Shaozhong SHI 2022-01-25 17:10:25 Counting the number of repeated phrases in a column
Previous Message Shaozhong SHI 2022-01-25 16:35:33 Re: Robust ways for checking allowed values in a column