create table tmp
(
id serial not null primary key,
name text,
age integer
);
insert into tmp (name,age) values ('keith', 43),('leslie', 40),('bexley', 19),('casey', 6);
update tmp
set age = data_table.age
from
(
select 'keith'::text as name, 44::integer as age
union
select 'leslie', 50
union
select 'bexley', 10
union
select 'casey', 12
) as data_table
where
tmp.name = data_table.name;
On Thu, Feb 3, 2011 at 7:00 AM, Gnanakumar <gnanam@xxxxxxxxxx> wrote:
> Hi,
>
> Is there a batch/bulk UPDATE query syntax available in PostgreSQL, similar
> to multirow VALUES syntax available for INSERT?
>
> INSERT Multirow VALUES syntax example:
> INSERT INTO films (code, title, did, date_prod, kind) VALUES
> ('B6717', 'Tampopo', 110, '1985-02-10', 'Comedy'),
> ('HG120', 'The Dinner Game', 140, DEFAULT, 'Comedy');
>
> There is a situation in my application, where I am performing lots and lots
> of updates on individual rows. I am trying to figure out how to make the
> updates faster.
>
> Any other ideas/ways to make updates faster are highly appreciated.
>
> Regards,
> Gnanam
>
>