Re: Robust ways for checking allowed values in a column - Mailing list pgsql-general

From Shaozhong SHI
Subject Re: Robust ways for checking allowed values in a column
Date
Msg-id CA+i5JwbTugb+J4GO1V_adBEhOK8vbBWdu0f0XTzvytGR72=BQw@mail.gmail.com
Whole thread Raw
In response to Re: Robust ways for checking allowed values in a column  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: Robust ways for checking allowed values in a column  (Rob Sargent <robjsargent@gmail.com>)
List pgsql-general
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.g.johnston@gmail.com> wrote:
On Tue, Jan 25, 2022 at 6:56 AM Shaozhong SHI <shishaozhong@gmail.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.

pgsql-general by date:

Previous
From: Tom Dearman
Date:
Subject: Re: tstzrange on large table gives poor estimate of expected rows
Next
From: Rob Sargent
Date:
Subject: Re: Robust ways for checking allowed values in a column