Solved

Delete orphan Records

Posted on 2011-09-28
3
571 Views
Last Modified: 2012-05-12
Could someone confirm this will delete orphan records from the child table Component where the Analysis and version don't exisit in the paretn table.

Parent key field are Name, Version
Child is Analayis, Version

component.analysis = analysis.name
DELETE ANALYSIS_VARIATION c where  NOT EXISTS (select name, version from analysis a where c.analysis = a.name and c.version=a.version)

Open in new window

0
Comment
Question by:gilnari
  • 2
3 Comments
 

Author Comment

by:gilnari
Comment Utility
sorry I grab the wrong script

DELETE component c where  NOT EXISTS (select name, version from analysis a where c.analysis = a.name and c.version=a.version)
0
 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
Comment Utility
Look like it should.  What makes you think it might not?

I suggest you create some sample tables with sample data and test it.
0
 

Author Comment

by:gilnari
Comment Utility
The database this has to run against I don't have access to and the person that is DBA does not understand Oracle SQL (long story and scary one at that).  I pretty sure it  will work but just watned a second opinion as if it goes wrong...oh that won't be good..   I did a short test on a different development system that I have locally and it seems to do what I wanted but the reason I have orphans is the first script that ran that was suppose to take care of the child then the parent.  However when it ran  and for r some reason the child stayed behind.  Guess it was bad parenting.

Better yet there is no relationships in the data base...thats right no ref int.   again a very long story..

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now