Newsletter Subscription | Glossary | Contact Us
Sample data
Home > All Categories > Oracle > Scripts > Cascade delete script
Question Title Cascade delete script
Authored by: Peter Boekelaar
Viewed: 2239 times so far
Why this script?
Most of the FK's defined in an Oracle DB, are not created using the on delete cascade option, since that is (most of the times) not wanted at all.
But sometimes records must be deleted while it is not allowed to do so, because there are child records (or a complete tree of child records) present.
For cases like that I use a script that searches the DB for child recs, using the SYS views.
 
Restrictions
The script only works on schema's where technical keys are used, i.e. primary keys that only contain one (numeric) column and the schema must be fully referential defined.
 
Usage
Fill in the local parameters SCHEMA_OWNER, MASTER_TABLE and MASTER_TABLE_ID. Execute the script. All underlying records will deleted using a recursive procedure. You can easely adjust the script by adding a cursor to delete multiple masterrecords.
 
enjoy!
Click Here to View all the questions in Scripts category.
File Attachments File Attachments
User Comments User Comments
User Comment christian.kindler@gmx.net on Wed, Jun 25th, 2008 at 6:22 AM
Too bad: The requested URL /admin/attachments/del_rec_cascade.sql was not found on this server. I could really use such a script.
User Comment vikas1975@hotmail.com on Thu, Jun 26th, 2008 at 6:45 AM
hi, this script cannot be downloaded. Is there any problem? Vikas
Post Comment Add a Comment
Email Address:
Comment/Message
Verify Code

Post Comment How helpful was this article to you?
Related Questions Related Article
  1. Drop all objects in the current schema
Article Information Additional Information
Article Number: 66
Created: 2008-01-29 2:49 AM
Rating 5 Stars
 
Article Options Article Options
Print Question Print this Question/Article
Email Question Email this Question/Article to Friend
Export to MS Word Export to MS Word
Bookmark Article
del.icio.us Bookmark del.icio.us Bookmark
Digg It Digg It
Furl It Furl It
Subscribe to Article Subscribe to Article
 
Language Translation Language Translation
 
Search Knowledge Base Search Knowledge Base