IT Community - Software Programming, Web Development and Technical Support

How can we delete master table record

This is a discussion on How can we delete master table record within the Database Support forums, part of the Web Development category; How can we delete master table records, where exists child records on them....


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > Database Support

Register FAQ Members List Calendar Mark Forums Read
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 08-08-2007, 01:13 AM
vadivelanvaidyanathan vadivelanvaidyanathan is offline
D-Web Genius
 
Join Date: Feb 2007
Posts: 803
vadivelanvaidyanathan is on a distinguished road
Wink How can we delete master table record

How can we delete master table records, where exists child records on them.
__________________
V.Vadivelan

There never a wrong time to do the right thing.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-08-2007, 03:22 AM
Murali Murali is offline
D-Web Master
 
Join Date: Feb 2007
Location: India-Chennai.
Posts: 386
Murali is on a distinguished road
Send a message via AIM to Murali
Default Re: How can we delete master table record

Hi,

Code:
CREATE TABLE EMPLOYEE_REGISTER
(
 EMP_ID  NUMBER PRIMARY KEY,
 EMP_SAL FLOAT
);


CREATE TABLE EMPLOYEE_DEPT
(
 DEPT_ID NUMBER PRIMARY KEY,
 DEPT_NAME    VARCHAR(100)
);


CREATE TABLE EMPLOYEE_DEPT_DETAILS
(
 EMP_DETAILS_ID  NUMBER PRIMARY KEY,
 EMP_EMP_ID   NUMBER NOT NULL,
 EMP_DEPT_ID  NUMBER NOT NULL,	 
 FOREIGN KEY(EMP_EMP_ID)REFERENCES EMPLOYEE_REGISTER(EMP_ID),
 FOREIGN KEY(EMP_DEPT_ID)REFERENCES EMPLOYEE_DEPT(DEPT_ID)
 );
 

 INSERT INTO EMPLOYEE_REGISTER VALUES (1,1000);
 INSERT INTO EMPLOYEE_DEPT VALUES (1,'IT');
 INSERT INTO EMPLOYEE_DEPT_DETAILS VALUES (1,1,1);

COMMIT;
 
DROP TABLE EMPLOYEE_REGISTER;
ORA-02449: unique/primary keys in table referenced by foreign keys

DELETE FROM EMPLOYEE_REGISTER CASCADE CONSTRAINTS Table Dropped.
__________________
-Murali..
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 08-08-2007, 03:29 AM
Murali Murali is offline
D-Web Master
 
Join Date: Feb 2007
Location: India-Chennai.
Posts: 386
Murali is on a distinguished road
Send a message via AIM to Murali
Default Re: How can we delete master table record

U mean to delete selected records from the parent table where exists a child table, then u can't.

Its an illegal one once u define referential constraints for the table u must be confirm there wont be any invalid records inserted in to the child table.

The only way is to delete the records from the child table then delete from the parent.
__________________
-Murali..
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

LinkBacks (?)
LinkBack to this Thread: http://www.discussweb.com/database-support/3219-how-can-we-delete-master-table-record.html
Posted By For Type Date
DiscussWeb IT Community - Fusing This thread Refback 08-08-2007 03:27 AM

Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete records from multiple table at a time Falcon Database Support 7 04-07-2008 01:12 AM
How to bind two master pages in a aspx page ? oxygen ASP and ASP.NET Programming 1 02-14-2008 08:35 PM
What is the difference between DELETE TABLE and TRUNCATE TABLE commands in SQL Server oxygen Database Support 6 11-23-2007 06:17 AM
how to get the last record only? senraj Database Support 8 08-24-2007 11:39 PM
How to delete a row from parent table that has relationship with the child tables? $enthil Database Support 5 08-14-2007 09:04 AM


All times are GMT -7. The time now is 03:50 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0