Subject Re: foreign Key Deletion
Author mspencewasunavailable
--- In, "Maurizio P."
<mauriz_po@...> wrote:
> hi ,
> i searched hours , but i could not find any help so
> i try to ask here (my first time) for an help :
> i thought that normally it would not be possible to
> delete a row which is a foreign key in another table ,
> the example :
> tableBanks
> -idBAnk(PK)
> -desBAnk
> tableCustomers
> -idCustomer(PK)
> -desCustomer
> -idBank (FK)
> ..ecc
> in this situation i can delete every tableCustomer row , even if
> exists as FK in the second table ,
> is it the normal behave ? how can i prevent it ?

I'm guessing you didn't tell it not to allow the delete, by
using "ON DELETE NO ACTION" when you defined the foreign key.

You can also ON DELETE CASCADE, which deletes the record on the
other side of the key, ON DELETE SET NULL, which sets the field in
the other record to NULL and ON DELETE SET DEFAULT, which sets the
field in the other record to its default value. If you don't say
anything, then you can just delete things at will.

ON DELETE and its buddy ON UPDATE are called Automatic Action
Triggers in Helen's book, and they're pretty standard items.

If you want something more exotic than what's provided by these, you
can define your own triggers.


Michael D. Spence
Mockingbird Data Systems, Inc.