Re: Update in all tables

From: Scott Marlowe <smarlowe(at)g2switchworks(dot)com>
To: Judith <jaltamirano(at)correolux(dot)com(dot)mx>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Update in all tables
Date: 2006-02-22 19:12:10
Message-ID: 1140635530.5777.32.camel@state.g2switchworks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, 2006-02-22 at 12:08, Judith wrote:
> Hello everybody I need to update a field with the same value in the
> tables of my data base but this field exists in almost all tables and
> has the same value, I don't want to code a script, so my question is if
> there is some way to update that field with a query and affects all the
> tables that contain the field?

Are those fields all dependent FK fields? If so, then declaring those
foreign keys as on update cascade is all you need.

If they're not related that way, then you'll have to script it.

If you need them all to change at the same time (or all roll back in the
event of an update failure) then you can wrap the changes in a
transaction (begin/end pair) and it'll be atomic.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Andrew Sullivan 2006-02-22 21:13:48 Re: Update in all tables
Previous Message Tom Lane 2006-02-22 18:58:24 Re: 'locking' the SELECTs based on indices...