473,884 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cascade Constraint

95 New Member
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.

Example

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 7338
ck9663
2,878 Recognized Expert Specialist
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
sonia.sardana
95 New Member
Dear CK ,i have read this from book navathe and from the site

http://www.careerencla ve.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
ck9663
2,878 Recognized Expert Specialist
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

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

Similar topics

0
5922
by: Fraser Hanson | last post by:
Hello, I have a table which has a foreign key relationship with itself. I want and expect my updates to cascade (deletes definitely cascade as expected) but instead I just get error 1217: foriegn key error. I have written example code to use in reproducing the problem: # Create the table
2
39438
by: Gunnar Vøyenli | last post by:
Hi! For the sake of simplicity, I have three tables, Employee, Department and Work Employee >---- Department \ / \ / ^ ^ Work
0
18828
by: Rob Panosh | last post by:
Hello, If I have table the following table structure: Table Customer ( CustomerId Numeric(10,0) Not Null, ... ) Table CustomerOrders ( CustomerOrderId As Numeric(10,0) Not Null, CustomerId Numeric(10,0) Not Null, CustomerRefId Numeric (10,0) Not Null, ... )
3
8231
by: SuryaPrakash Patel via SQLMonster.com | last post by:
Hello, There are three tables: OS-GroupOFCompanies (Table1) GoC_GroupOFCompaniesID (PK) OS-Organization (Table 2) Org_OrganizationID (PK)
2
11520
by: P.B. via SQLMonster.com | last post by:
I cannot execute my sql to create a table with ON DELETE CASCADE option. Here is my sql: CREATE TABLE Employees (Name Text(10) not null, Age number, CONSTRAINT pkEmployees PRIMARY KEY (Name)); <--- This is ok! CREATE TABLE CanTake (Name Text(10) not null, Make Text(10) not null, CONSTRAINT pkCanTake PRIMARY KEY (Name, Make),
4
33690
by: Jean-Christian Imbeault | last post by:
Currently I have a table defined as such: TAL=# \d internal_keywords Table "public.internal_keywords" Column | Type | Modifiers ---------+---------+----------- keyword | text | not null pid | integer | not null Indexes: internal_keywords_pkey primary key btree (keyword, pid) Foreign Key constraints: $1 FOREIGN KEY (pid) REFERENCES products(id) ON
1
3505
by: Baldur Norddahl | last post by:
Hi, I just noticed that I could do this: webshop=# create table foo (bar text not null primary key); NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "foo_pkey" for table "foo" CREATE TABLE webshop=# create table foo2 (bar text not null, foreign key (bar) references foo(bar) on update cascade on delete set null);
14
5859
by: Karl O. Pinc | last post by:
Hi, Thought perhaps some other eyes than mine can tell if I'm doing something wrong here or if there's a bug somewhere. I've never passed a ROWTYPE varaible to a function but I don't see where the problem is. I keep getting errors like (the first is my debug output): NOTICE: last cycle is: 11 WARNING: Error occurred while executing PL/pgSQL function
26
2123
by: Allen Browne | last post by:
In Access 2000 and later, you can create a relation between tables where related records can be automatically set to Null rather than deleted when the primary record is deleted. I have not seen anyone using or discussing this feature, so there is a new article explaining the concept here: Cascade to Null Relations at: http://allenbrowne.com/ser-64.html
1
10907
by: HH | last post by:
I try to make a script for generating backend databases. When I try to make a relationship between a table named 'users' and another table name 'layouts' an error occurs. Option 1: CurrentDB.Execute "ALTER TABLE layouts ADD CONSTRAINT users_layouts FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE" Option 2: DoCmd.RunSQL "ALTER TABLE layouts ADD CONSTRAINT users_layouts FOREIGN
0
9954
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9799
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10426
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9591
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7137
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5808
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6009
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4623
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3242
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.