views:

50

answers:

1

Given databases x, y with matching schemas:

//for all entries in x.MY_TABLE
//        if PRIMARY_KEY of entry exists in y.MY_TABLE
//            if {data of entry in x} doesn't match {data of matching entry in y}
//                print PRIMARY_KEY
//        else
//            print PRIMARY_KEY

Assume that the table is a simple system with at most a 2-column primary key.

+3  A: 

So you want a list of all primary keys in x unless the key and data (i.e. the entire row) is the same. I think this should do it.

SELECT PRIMARY_KEY
FROM
(
SELECT * FROM x.MY_TABLE
MINUS
SELECT * FROM y.MY_TABLE
) T;
Martin Smith
SQL Error: ORA-00933: SQL command not properly ended00933. 00000 - "SQL command not properly ended
deworde
@deworde - I changed the `EXCEPT` that was originally there to `MINUS`
Martin Smith
Looks good. Thanks.
deworde
What's the T do?
deworde
That's just an alias for the derived table defined inside the parentheses.
Martin Smith