-
Contributing Member
ON DELETE CASCADE option
Can I add ON DELETE CASCADE option to an existing FOREIGN KEY using alter.
-
Re: ON DELETE CASCADE option
Yes that can be specified.
-
Expert Member
Re: ON DELETE CASCADE option
First you drop the existing constraint.
Alter table drop constraint constraintname;
ex:- alter table drop constraint fk_dept
Then once again add the constraint.
alter table add constraint constraintname foreign key(deptno)
references dept(deptno) on delete cascade
ex:- alter table add constraint dept_emp foreign key(deptno)
references dept(deptno) on delete cascade
Last edited by krishnaindia2007; 11-22-2007 at 04:48 AM.
-
Expert Member
Re: ON DELETE CASCADE option
First Drop foreign key constraint using below command
alter table emp drop constraint fk1
After that add fk constraint, cascade option using this command
ALTER TABLE dept
ADD CONSTRAINT fk1
FOREIGN KEY (deptno)
REFERENCES emp(dno) ON DELETE CASCADE;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules