Updating an array

From: Renaud Tthonnart <thonnart(at)amwdb(dot)u-strasbg(dot)fr>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Updating an array
Date: 2001-02-23 17:02:30
Message-ID: 3A9697A6.578FB837@amwdb.u-strasbg.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alex Pilosov 2001-02-23 17:13:55 Re: drop a constraint
Previous Message Stephan Szabo 2001-02-23 16:50:59 Re: OIDs in triggers