简体   繁体   English

如何在Oracle PL / SQL中编写此数据库比较?

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

Given databases x, y with matching schemas: 给定具有匹配模式的数据库x,y:

//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. 假设该表是一个简单的系统,最多具有2列主键。

So you want a list of all primary keys in x unless the key and data (ie the entire row) is the same. 因此,除非键和数据(即整行)相同,否则您需要x中所有主键的列表。 I think this should do it. 我认为应该这样做。

SELECT PRIMARY_KEY
FROM
(
SELECT * FROM x.MY_TABLE
MINUS
SELECT * FROM y.MY_TABLE
) T;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM