Tim Tim - 1 year ago 111
SQL Question

Update whole row in PostgreSQL

I need to update a whole row without knowing the columns and rows...

Something like this:

UPDATE blabla SET blabla.* = tmp.* FROM tmp WHERE id = someid;

Has anyone ideas??

Thanks for answers

Answer Source

I don't think Postgres allows this. One simple solution is two separate steps:

delete from blabla where id = someid;

insert into blabla
    select * from tmp where id = someid;

This assumes that the columns are defined in the same order.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download