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....
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| How can we delete master table records, where exists child records on them. |
| Sponsored Links |
| |||
| 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.. |
| |||
| 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.. |
![]() |
| Thread Tools | |
| Display Modes | |
| |
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 |