utPLSQL:如何比较两个表? [英] utPLSQL: How can i compare two tables?

查看:65
本文介绍了utPLSQL:如何比较两个表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有表1和表2.表2是表1的更新版本.它可以具有相同或更新的结构,列和数据.我想比较这两个表.

Lets say i have table 1 and table 2. Table 2 is the updated version of table one. It can have same or updated structure, columns and data. I want to compare those two tables.

推荐答案

我的要求是使用utPLSQL比较两个表的列,数据和约束. 我通过使用本机反射器满足了我的要求.

My requirement was to compare columns, data and constraints of two tables using utPLSQL. i met my requirement by using native refcursors.

用于数据比较:

OPEN p_store FOR SELECT * FROM customers@dblink2;
OPEN p_store2 FOR SELECT * FROM customers2@dblink2;
ut.expect(p_store).to_equal(p_store2);

用于列比较:

OPEN p_store FOR
SELECT
    A.COLUMN_NAME,
    A.DATA_TYPE,
    A.DATA_LENGTH
FROM
    (SELECT * FROM USER_TAB_COLUMNS@dblink2 WHERE TABLE_NAME  = 'CUSTOMERS') A;
OPEN p_store2 FOR
SELECT
  B.COLUMN_NAME,
  B.DATA_TYPE,
  B.DATA_LENGTH
FROM
  (SELECT * FROM user_tab_columns@dblink2 WHERE table_name = 'CUSTOMERS') B;
ut.expect(p_store).to_equal(p_store2);

我使用utPLSQL V3.如果您使用的是v2,则可以使用 utassert.eqtable .

I using utPLSQL V3. If you're using v2 then utassert.eqtable can be used.

这篇关于utPLSQL:如何比较两个表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆