zoukankan      html  css  js  c++  java
  • ETL-拉链算法-带删除的拉链算法

    truncate table CUST;truncate table TAG_CUST;
    truncate table vt_inc;truncate table vt_new;
    insert into CUST values(100,'张三','13333333333');
    insert into CUST values(200,'李四','12222222222');
    insert into CUST values(300,'王五','15555555555');
    insert into vt_new
        select CUST_ID,CUST_NAME,PHONE_NUM,'20160101','29991231' from CUST;
    insert into vt_inc
        select a.* from vt_new a
            left join TAG_CUST b on a.CUST_ID=B.CUST_ID and b.ETL_END_DT='29991231'
            where b.CUST_ID is null or a.PHONE_NUM<>b.PHONE_NUM;
    insert into vt_inc
        select b.CUST_ID,a.CUST_NAME,a.PHONE_NUM,a.ETL_START_DT,'19990101' from vt_new a
            right join TAG_CUST b
                on a.CUST_ID=b.CUST_ID
                 where a.CUST_ID is null and b.ETL_END_DT='29991231';
    update TAG_CUST a set ETL_END_DT='20160102'
        where ETL_END_DT='29991231' and exists
        (select 1 from vt_inc b
         where a.CUST_ID=b.CUST_ID);
    insert into TAG_CUST
        select a.* from vt_inc a where a.ETL_END_DT='29991231';
    
    
  • 相关阅读:
    [日料探店] 食一料理
    工地英语
    C++20协程解糖
    C++20协程解糖
    C++20协程解糖
    单表操作
    数据库查询语句罗列
    数据库简易介绍
    mysql的常用操作
    css基础
  • 原文地址:https://www.cnblogs.com/fengzzi/p/10045494.html
Copyright © 2011-2022 走看看