Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Delete orphan Records

Posted on 2011-09-28
3
Medium Priority
?
603 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Author Comment

by:gilnari
ID: 36720051
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 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 2000 total points
ID: 36720350
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
ID: 36814798
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.

730 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