X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id A99F19DC87A for ; Wed, 22 Feb 2006 15:12:13 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 63825-07 for ; Wed, 22 Feb 2006 15:12:13 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from exchange.g2switchworks.com (mail.g2switchworks.com [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id E195A9DC877 for ; Wed, 22 Feb 2006 15:12:10 -0400 (AST) Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; Wed, 22 Feb 2006 19:12:10 +0000 Received: from state.g2switchworks.com by mail.g2switchworks.com; 22 Feb 2006 13:12:10 -0600 Subject: Re: Update in all tables From: Scott Marlowe To: Judith Cc: pgsql-sql@postgresql.org In-Reply-To: <43FCA8B0.3050803@correolux.com.mx> References: <43FCA8B0.3050803@correolux.com.mx> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1140635530.5777.32.camel@state.g2switchworks.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Wed, 22 Feb 2006 13:12:10 -0600 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.157 required=5 tests=[AWL=0.156, UNPARSEABLE_RELAY=0.001] X-Spam-Score: 0.157 X-Spam-Level: X-Archive-Number: 200602/271 X-Sequence-Number: 24281 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.