Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: SQL vs Perl table comparing

by CubicSpline (Friar)
on Nov 07, 2002 at 18:46 UTC ( [id://211180]=note: print w/replies, xml ) Need Help??


in reply to SQL vs Perl table comparing

I think you are right to question your approach here. Relational databases were made to do the kind of thing you're talking about here. Let's look at how you'd do these things.

Let's assume you have Table and BackupTable, which have the exact same columns and a primary key named 'Key'.

1. records existing only in first table

SELECT * FROM Table WHERE NOT EXISTS (SELECT * FROM BackupTable WHERE Table.Key = BackupTable.Key)

2. records existing only in second table

Same thing as 1, but switch the table names.

3. records with identical primary keys, but with different content.

The best I can think of here is to get a list of the primary key values that are in both tables but have different values.

SELECT Key FROM Table LEFT JOIN BackupTable ON Table.Key = BackupTable +.Key WHERE Table.column1 <> BackupTable.column1 OR Table.column2 <> B +ackupTable.column2 ......
Hopefully, Oracle provides some sort of utility to do this, but if I had to do it through straight SQL those are the things I would try.

Good Luck.

~CubicSpline
"No one tosses a Dwarf!"

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://211180]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-25 21:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found