Re: Update in all tables

From: Janning Vygen <vygen(at)gmx(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Update in all tables
Date: 2006-02-22 18:33:36
Message-ID: 200602221933.36387.vygen@gmx.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Am Mittwoch, 22. Februar 2006 19:08 schrieb Judith:
> 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?

no. but you can do with a trigger ON UPDATE

but what is so evil about a script like this:

#!/bin/sh
TABLES="A B C D"
for TAB in $TABLES
do
psql -c "UPDATE $TAB set field = 'new' where field = 'old'" mydbname;
done

In response to

Browse pgsql-sql by date

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