Updating an array

Поиск
Список
Период
Сортировка
От Renaud Tthonnart
Тема Updating an array
Дата
Msg-id 3A9697A6.578FB837@amwdb.u-strasbg.fr
обсуждение исходный текст
Ответы Re: Updating an array  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
How can I append an element to an array, without read and rewrite the
full array.

CREATE TABLE xxx
(
 id int,
 nom varchar(10),
 nombres int[],

 PRIMARY KEY(id)

);

*** 1 ***
INSERT INTO xxx VALUES( 1,'aaa','{10,20,30,40}');
==> Here the row is well created.

*** 2 ***
UPDATE xxx
SET nombres[5]= 63
WHERE id = 1;
==> Here, I'd just append a new element to the array. That doesn't work

*** 3 ***
UPDATE xxx
SET nombres= '{10,20,30,40,63}'
WHERE id = 1;
==> That works, but needs to read out the array and to rewrite it. Is it
possible to avoid that?

Thanks,
Renaud THONNART



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

Предыдущее
От: ochapiteau
Дата:
Сообщение: drop a constraint
Следующее
От: Alex Pilosov
Дата:
Сообщение: Re: drop a constraint