472,144 Members | 1,935 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,144 software developers and data experts.

Cascade Constraint

Que-What is the use of CASCADE CONSTRAINTS?

Ans-When this clause is used with the DROP command, a parent table can be dropped even when a child table exists.


create table primary1(roll int primary key,name varchar)
insert into primary1 values(1,'A')
insert into primary1 values(2,'B')
select * from primary1

create table foreign1(roll1 int references primary1(roll),address varchar(10))
insert into foreign1 values(1,'Delhi')
insert into foreign1 values(2,'Fbd')
select * from foreign1

If i write DROP TABLE PRIMARY1,table cannot be dropped.Its right.

If i write drop table primary1 CASCADE, it means that primary1 table can be deleted even if it referenced by foreign1............If i m not wrong.......

But the primary1 table is not deleting when i write drop table primary1 CASCADE,
ERROR is coming Incorrect syntax near the keyword 'CASCADE'.

Your Prompt Reply will be appreciated.
Mar 15 '08 #1
3 7164
2,878 Expert 2GB
Where did you get that answer? I believe CASCADE can be used in deleting records, not dropping the entire table.

Here's more.

-- CK
Mar 17 '08 #2
Dear CK ,i have read this from book navathe and from the site

http://www.careerenclave.com/freshers-walkins.htm--> Then click on Right hand side-->database FAQs-->SQL interview Q&A - 2 -->Question No 11.

Read it & pleas reply
Mar 17 '08 #3
2,878 Expert 2GB
Here's the complete DROP TABLE syntax. I don't see any CASCADE on it.

I could be mistaken. He could be right.

-- CK
Mar 18 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Fraser Hanson | last post: by
2 posts views Thread by Gunnar Vøyenli | last post: by
reply views Thread by Rob Panosh | last post: by
3 posts views Thread by SuryaPrakash Patel via SQLMonster.com | last post: by
2 posts views Thread by P.B. via SQLMonster.com | last post: by
4 posts views Thread by Jean-Christian Imbeault | last post: by
1 post views Thread by Baldur Norddahl | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.