Re: Check constraints for varchar[] and varchar[][] columns in a table
В списке pgsql-general по дате отправления:
| От | Tom Lane |
|---|---|
| Тема | Re: Check constraints for varchar[] and varchar[][] columns in a table |
| Дата | |
| Msg-id | 6497.1457106813@sss.pgh.pa.us обсуждение |
| Ответ на | Check constraints for varchar[] and varchar[][] columns in a table (Alexander Farber <alexander.farber@gmail.com>) |
| Ответы |
Re: Check constraints for varchar[] and varchar[][] columns
in a table
|
| Список | pgsql-general |
Alexander Farber <alexander.farber@gmail.com> writes:
> I am trying to add CHECK constraints to the VARCHAR arrays:
> hand1 varchar[7] NOT NULL CHECK (ALL(hand1) ~ '^[*A-Z]$'),
> but get syntax errors near "ALL"
> - probably because that keyword is supposed to be on the right side?
Yeah, the syntax has to be "scalar operator ALL (array)".
> Could anyone please recommend a way to implement check constraints here?
The workaround that's been suggested in the past is to define a reversed
pattern match operator, ie one that has the pattern on the left. There's
no such thing in the core PG distribution, but the only hard part of making
your own is figuring out what to name the operator ;-)
regards, tom lane
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера