Re: Update in all tables - Mailing list pgsql-sql

From Janning Vygen
Subject Re: Update in all tables
Date
Msg-id 200602221933.36387.vygen@gmx.de
Whole thread Raw
In response to Update in all tables  (Judith <jaltamirano@correolux.com.mx>)
List 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



pgsql-sql by date:

Previous
From: Judith
Date:
Subject: Update in all tables
Next
From: Tom Lane
Date:
Subject: Re: 'locking' the SELECTs based on indices...