如果不能建立dblink,那么就只能导出两行表,通过spool导出就可以。然后通过系统级别的命令去比对。我记得linux是有比较两个文件不同行的功能的。
如果认为两个都导出比较麻烦,那就导出一个,在导入另外一个库(注意变换名字,否则表明重复就麻烦了),然后再对比。
select * from A minus select * from Bselect * from B minus select * from A
比较表结构相同的两表之间的差异用minus。
例如:核对web层和mid层保费收入的差异:首先把这两个模块看做两张表,而且这两个模块出的字段一致,需要编号和钱,核对这个钱的数据为啥不对。
①WEB层
SELECT SUM(A.PREMIUMCNY) "保费收入(含税) "
FROM WEB_XG_SALESMAN_RISK_ALL A
WHERE TRUNC(A.STATDATE) BETWEEN DATE '2019-09-01' AND DATE '2019-09-30'
②MID层
SELECT SUM(NVL(A.PREMIUM, 0)) AS 保费收入
FROM MID_CB_PREMIUM_RISK_ALL A
WHERE TRUNC(A.STATDATE) BETWEEN DATE'2019-09-01' AND DATE'2019-09-30'
----------------------------------------------------------------------------------------
结果:(需要把两个模块的编号 和 钱 都写出来)
SQL:
SELECT A.POLICYNO, --编号
SUM(A."保费收入(含税) ") AS BFSRHS,
B.POLICYNO,
SUM(B.保费收入) AS BFSR
FROM
(SELECT A.POLICYNO,SUM(A.PREMIUMCNY) "保费收入(含税) "
FROM WEB_XG_SALESMAN_RISK_ALL A
WHERE TRUNC(A.STATDATE) BETWEEN DATE '2019-09-01' AND DATE '2019-09-30'
GROUP BY A.POLICYNO
) A
FULL JOIN
(SELECT A.POLICYNO,SUM(NVL(A.PREMIUM, 0)) AS 保费收入
FROM MID_CB_PREMIUM_RISK_ALL A
WHERE TRUNC(A.STATDATE) BETWEEN DATE'2019-09-01' AND DATE'2019-09-30'
GROUP BY A.POLICYNO
) B
ON A.POLICYNO = B.POLICYNO --用编号关联
WHERE A.POLICYNO IS NULL OR B.POLICYNO IS NULL --是否一致
OR A.BFSRHS <>B.BFSR
group BY A.POLICYNO,
B.POLICYNO
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)