Обсуждение: Update in all tables

Поиск
Список
Период
Сортировка

Update in all tables

От
Judith Altamirano Figueroa
Дата:
    Hello everybody I need to update a field with the same value in the tables of my data base but this field exists
inalmost 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
updatethat field with a query and affects all the tables that contain the field?<br /><br />     Thanks in advanced,
regards!!! 

Re: Update in all tables

От
Andrew Sullivan
Дата:
On Wed, Feb 22, 2006 at 11:59:06AM -0600, Judith Altamirano Figueroa 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?

No, sorry.  While we're at it, though, if you have the same field in
several tables, it's a good sign that your database is badly
normalised.  You shouldn't have to update more than one table (which
is why there isn't a way to do this automatically).

A

-- 
Andrew Sullivan  | ajs@crankycanuck.ca
Unfortunately reformatting the Internet is a little more painful 
than reformatting your hard drive when it gets out of whack.    --Scott Morris


Re: Update in all tables

От
Scott Marlowe
Дата:
On Wed, 2006-02-22 at 15:13, Andrew Sullivan wrote:
> On Wed, Feb 22, 2006 at 11:59:06AM -0600, Judith Altamirano Figueroa 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?
> 
> No, sorry.  While we're at it, though, if you have the same field in
> several tables, it's a good sign that your database is badly
> normalised.  You shouldn't have to update more than one table (which
> is why there isn't a way to do this automatically).

Unless they're all FK/PK pairs, in which case you on update / delete
cascade FKs.


Re: Update in all tables

От
"Owen Jacobson"
Дата:
Scott Marlowe wrote:

> On Wed, 2006-02-22 at 15:13, Andrew Sullivan wrote:
>
> > No, sorry.  While we're at it, though, if you have the same field in
> > several tables, it's a good sign that your database is badly
> > normalised.  You shouldn't have to update more than one table (which
> > is why there isn't a way to do this automatically).
>
> Unless they're all FK/PK pairs, in which case you on update / delete
> cascade FKs.

It's entirely too bad this has to be designed into the DDL for the table.  It'd be nice if you could specify "CASCADE"
onUPDATE or DELETE queries.  I don't see that it's any more of a gun than ON UPDATE/ON DELETE CASCADE in the foreign
keydefinition. 

-Owen