Tim Tim - 2 months ago 26
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

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.