Re: Add a check an a array column

Поиск
Список
Период
Сортировка
От vdg
Тема Re: Add a check an a array column
Дата
Msg-id 4125633.DgHRScKsx9@vdg-dev
обсуждение исходный текст
Ответ на Re: Add a check an a array column  (Bret Stern <bret_stern@machinemanagement.com>)
Ответы Re: Add a check an a array column  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Add a check an a array column  (Gavin Flower <GavinFlower@archidevsys.co.nz>)
Список pgsql-general
Thanks for your help.

Before posting, I had tried something like

check ((ALL(i) >= 0) AND (ALL(i) <= 1024  )));

but i got syntax errors.
It seems the first ALL() was not recognized.

Could someone give me documentation hints on this behaviour ?

vdg


On Saturday, 08 September 2012 13:18:25 Bret Stern wrote:
> On Sat, 2012-09-08 at 21:24 +0200, Andreas Kretschmer wrote:
> > Joel Hoffman <joel.hoffman@gmail.com> wrote:
> > > More concisely, you can compare directly against all values of the
> > > array:
> > >
> > > # create table i (i int[] check (0 <= ALL(i) AND 1023 >= ALL(i)));
> > > # insert into i values (ARRAY[0,1,2,3,1023]);
> > > # insert into i values (ARRAY[0,1,2,3,-1]);
> > > ERROR:  new row for relation "i" violates check constraint "i_i_check"
> >
> > Nice! Didn't know that with all()
>
> A better place for validation is in the front-end, before
> adding/attempting to add data to the db (my opinion).
> Nice to see there are always other ways though.
>
> > Andreas


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

Предыдущее
От: Tomas Vondra
Дата:
Сообщение: Re: Index creation takes more time?
Следующее
От: Thomas Kellerer
Дата:
Сообщение: Re: Add a check an a array column