轉自    http://www.gold98.net/blog/article.asp?id=125
不能刪除包含主鍵的行,該主鍵被用做另一個表的外鍵

Error: orA-02292: integrity constraint <constraint name> violated - child record found 
Cause: You tried to Delete a record from a parent table (as referenced by a foreign key), but a record in the child table exists. 
Action: The options to resolve this oracle error are: 
This error commonly occurs when you have a parent-child relationship established between two tables through a foreign key. You then have tried to delete a value into the parent table, but the corresponding value exists in the child table. 
To correct this problem, you need to update or delete the value into the child table first and then you can delete the corresponding value into the parent table.



For example, if you had created the following foreign key (parent-child relationship).

Create TABLE supplier 
( supplier_id numeric(10) not null, 
 supplier_name varchar2(50) not null, 
 contact_name varchar2(50),  
 CONSTRAINT supplier_pk PRIMARY KEY (supplier_id) 
); 

Create TABLE products 
( product_id numeric(10) not null, 
 supplier_id numeric(10) not null, 
 CONSTRAINT fk_supplier 
   FOREIGN KEY (supplier_id) 
   REFERENCES supplier (supplier_id) 
); 



Then you try inserting into the products table as follows:

Insert INTO supplier
(supplier_id, supplier_name, contact_name)
VALUES (1000, 'Microsoft', 'Bill Gates');

Insert INTO products
(product_id, supplier_id)
VALUES (50000, 1000);



Then you tried to delete the record from the supplier table as follows:

Delete from supplier
Where supplier_id = 1000;



You would receive the following error message:




Since the supplier_id value of 100 exists in the products,  you need to first delete the record from the products table as follows:

Delete from products
Where supplier_id = 1000;

Then you can delete from the supplier table:

Delete from supplier
Where supplier_id = 1000;


不能刪除包含主鍵的行,該主鍵被用做另一個表的外鍵

完整性約束錯誤

如果你嘗試刪除一條記錄,該記錄中的值依賴一個完整性約束,一個錯誤被返回。

某例子試圖從DEPARTMENTS表中刪除部門號60,但執行該語句將返回一個錯誤,因為部門號在EMPLOYEES表中被用做外鍵。如果你試圖刪除的父記錄有子記錄,那么,你將收到child record found violation orA-02292。
下面的語句可以正常工作,因為在部門70中沒有雇員:
Delete FROM departments
Where department_id = 70;
1 row deleted.

注釋

如果使用了引用完整性約束,當你試圖刪除一行時,你可能收到一個Oracle服務器錯誤信息。但是,如果引用完整性約束包含了ON Delete CASCADE選項,那么,可以刪除行,并且所有相關的子表記錄都被刪除。