开发者

How do I write this database comparison in Oracle PL/SQL?

开发者 https://www.devze.com 2023-01-13 00:40 出处:网络
Given databases x, y with matching schemas: //for all 开发者_运维百科entries in x.MY_TABLE //if PRIMARY_KEY of entry exists in y.MY_TABLE

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.


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;
0

精彩评论

暂无评论...
验证码 换一张
取 消