拉链表、增量表、全量表

拉链表、增量表、全量表

拉链表

记录一个事物从开始到当前状态的所有的变化信息。适用于“数据量非常大的表、表中的某些字段会被更新操作、需要查看历史信息、表的数据更新变化不是很大。”拉链表中会定义数据的st_date和end_date。

初始表A

cust_idaccountst_dtend_dt
a1002017080129991231
b2002017080129991231
c1002017080129991231

20170802:更新数据表B

cust_idaccountst_dtend_dt
a2002017080229991231
b3002017080229991231

更新表A

update A
set  end_dt=mat_date
where cust_id in (select cust_id from B)
cust_idaccountst_dtend_dt
a1002017080120170802
b2002017080120170802
c1002017080129991231

导入更新数据B

insert into A select * from B

得到最终表:

cust_idaccountst_dtend_dt
a1002017080120170802
b2002017080120170802
c1002017080129991231
a2002017080229991231
b3002017080229991231

增量表

只保留当前新增的数据,例如:

初始表A

cust_idaccountst_dt
a10020170801
b20020170801
c10020170801

2017年8月2日:a账户又存了300

cust_idaccountst_dt
a30020170802

最终表

cust_idaccountst_dt
a30020170802
a10020170801
b20020170801
c10020170801

全量表

保存用户所有的数据(包括新增与历史数据),例如:

初始表A

cust_idaccountst_dt
a10020170801
b20020170801

2017年8月2日:a账户没存、b账户没存、c账户存200

cust_idaccountst_dt
a10020170802
b20020170802
c10020170802

最终表

cust_idaccountst_dt
a10020170801
b20020170801
a10020170802
b20020170802
c10020170802
  • 4
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值