Subject Re: FKs: distinction between RESTRICT and NO ACTION
Author Adam
I never use no action or restrict, but I doubt they are equivalent.

To me, no action means do nothing if the parent key is changed.
Restrict means raise an exception if you try and change the parent
key and there is a child for it.

I always use on update cascade or on update set to null depending on
what I am doing.

Adam

--- In firebird-support@yahoogroups.com, Milan Babuskov <milanb@k...>
wrote:
> Hello all,
>
> I came across and interesting issue. First version, I create
foreign key like this:
>
> alter table TABLE2 add constraint FK_TABLE2_1
> foreign key ( x ) references TABLE1 ( x )
> on update NO ACTION;
>
> Second version:
>
> alter table TABLE2 add constraint FK_TABLE2_1
> foreign key ( x ) references TABLE1 ( x );
>
> The effect seems to be the same. However, when I query the system
tables there
> is a difference:
>
> select r.rdb$constraint_name, c.rdb$update_rule
> from rdb$relation_constraints r, rdb$ref_constraints c
> where r.rdb$relation_name = 'TABLE2'
> and r.rdb$constraint_name = c.rdb$constraint_name
> and (r.rdb$constraint_type='FOREIGN KEY')
>
> In first case, for RDB$UPDATE_RULE column the value stored is 'NO
ACTION' and in
> second case it's 'RESTRICT'.
>
> Is RESTRICT equal to NO ACTION? Why do they exist?
>
> BTW, is the devel list more appropriate for this kind of questions?
>
> --
> Milan Babuskov
> http://fbexport.sourceforge.net
> http://www.flamerobin.org