【问题标题】:How to find differences between the same table but from 2 databases(snowflake/sql)如何找到同一个表之间的差异,但来自 2 个数据库(snowflake/sql)
【发布时间】:2022-12-22 00:30:22
【问题描述】:

所以我有一个在测试和生产中的表,我想检查“code_num”列是否有任何差异。我需要这样做来验证表是否已正确迁移。

有没有一种简单的方法可以通过 SQL 来做到这一点

【问题讨论】:

    标签: sql snowflake-cloud-data-platform


    【解决方案1】:

    您应该能够从同一个 Web 界面访问 prod 和 dev。根据您的设置,您可以访问 select * from prod.myschema.mytable 之类的产品数据并通过 select * from test.myschema.mytable 进行测试。

    然后你可以很容易地比较它们,如下所示 -

    --code_num in test but not in prod
    select * from test.myschema.mytable where code_num not in (select code_num from prod.myschema.mytable);
    --code_num in prod but not in test
    select * from prod.myschema.mytable where code_num not in (select code_num from test.myschema.mytable);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-20
      • 1970-01-01
      • 2017-05-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-02
      相关资源
      最近更新 更多