Subject | Re: [firebird-support] Cascading updates? |
---|---|
Author | Norman Dunbar |
Post date | 2011-06-13T06:56:47Z |
On 12/06/11 21:03, heineferreira wrote:
In a foreign key relationship, there is the ability to cascade deletes
and cascade updates.
You specify that updates are to be cascaded by the ON UPDATE clause when
you create the FK. Similarly, the ON DELETE clause defines what happens
when the parent row is deleted.
May I recommend that you take a look at the Firebird Book by Helen
Borrie as an excellent source of Firebird knowledge; and/or pay a visit
to the documentation project and get hold of (a) the old Interbase docs
and then grab some of the more up to date docs as well.
Interbase docs are here:
http://www.firebirdsql.org/en/reference-manuals/ scroll to the bottom
for the Interbase manuals, you will need at least the language guide:
http://www.firebirdsql.org/file/documentation/reference_manuals/interbase_60_manuals/InterBase60_LangRef.zip
Anyway, the full spec of adding a FK with cascading updates to a table
would be:
ALTER TABLE T
ADD CONSTRAINT T_FK FOREIGN KEY (FK_ID)
REFERENCES PARENT_T (PARENT_ID)
ON DELETE NO ACTION
ON UPDATE CASCADE;
There are other clauses available such as USING INDEX plus the parent
column(s) are optional - if not there, the Primary Key will be used.
Have fun.
Cheers,
Norm.
--
Norman Dunbar
Dunbar IT Consultants Ltd
Registered address:
Thorpe House
61 Richardshaw Lane
Pudsey
West Yorkshire
United Kingdom
LS28 7EL
Company Number: 05132767
> Does Firebird 2.5 do the Cascading of updates?Depends on what you mean by cascading of updates.
> May be you call it something else?
In a foreign key relationship, there is the ability to cascade deletes
and cascade updates.
You specify that updates are to be cascaded by the ON UPDATE clause when
you create the FK. Similarly, the ON DELETE clause defines what happens
when the parent row is deleted.
May I recommend that you take a look at the Firebird Book by Helen
Borrie as an excellent source of Firebird knowledge; and/or pay a visit
to the documentation project and get hold of (a) the old Interbase docs
and then grab some of the more up to date docs as well.
Interbase docs are here:
http://www.firebirdsql.org/en/reference-manuals/ scroll to the bottom
for the Interbase manuals, you will need at least the language guide:
http://www.firebirdsql.org/file/documentation/reference_manuals/interbase_60_manuals/InterBase60_LangRef.zip
Anyway, the full spec of adding a FK with cascading updates to a table
would be:
ALTER TABLE T
ADD CONSTRAINT T_FK FOREIGN KEY (FK_ID)
REFERENCES PARENT_T (PARENT_ID)
ON DELETE NO ACTION
ON UPDATE CASCADE;
There are other clauses available such as USING INDEX plus the parent
column(s) are optional - if not there, the Primary Key will be used.
Have fun.
Cheers,
Norm.
--
Norman Dunbar
Dunbar IT Consultants Ltd
Registered address:
Thorpe House
61 Richardshaw Lane
Pudsey
West Yorkshire
United Kingdom
LS28 7EL
Company Number: 05132767