ETL拉鍊演算法彙總大全

2021-09-07 13:17:57 字數 3195 閱讀 8090

拉鍊演算法總結大全:

一、0610演算法(追加)

1、刪除倉庫表的載入日期是本次載入日期的資料,以支援重跑

delete from *** where start_dt >=$tx_date;

2、建立暫時表,用於存放從源表中提取的資料

create multiset volatile table ***;

3、向暫時表中插入資料。依照一定規則加工

insert into *** select ... from ***;

4、對於暫時表的資料打上時間戳直接插入倉庫表中

insert into *** select ... from ***;

二、0611演算法(全刪全插)

1、將倉庫表中主鍵處於源表的字段記錄刪除

delete from *** where (id) in (select id  from ***);

2、將源表的全部資料直接插入到倉庫表中

insert into *** select ... from ***;

三、0612演算法(歷史拉鍊演算法)

1、刪除倉庫表的載入日期是本次載入日期的資料,用於支援重跑

delete from *** where start_dt >= $tx_date;

2、改動倉庫表的結束日期字段。作用是把結束日期大於載入日期而且不是最大日期的資料的結束日期置為最大日期。使其有效

update set end_dt=$max_dt where end_dt >= $tx_date and end_dt <> max_dt;

3、建立暫時表用於存放從源表中提取的資料

create multiset volatile table new;

4、建立暫時增量表用於存放增量資料

create multiset volatile table inc;

5、依據一定的規則向暫時表中載入源表資料,依據需求而定

insert into new select ... from  *** where ...;

6、用暫時表的資料與倉庫表資料作對照,將新增和更改的資料存入增量表中

insert into inc select ... from new where .. not in ..;

7、對全部在增量表的而且是有效的資料進行關鏈處理

update *** set end_dt=$tx_date where ...;

8、對全部處於增量表中的資料進行拉新鏈處理

insert into *** select ... from inc;

四、0614(帶刪除的歷史拉鍊演算法)

1、刪除倉庫表的載入日期是本次載入日期的資料,用於支援重跑

delete from *** where start_dt >= $tx_date;

2、改動倉庫表的結束日期字段。作用是把結束日期大於載入日期而且不是最大日期的資料的結束日期置為最大日期。使其有效

update set end_dt=$max_dt where end_dt >= $tx_date and end_dt <> max_dt;

3、建立暫時表用於存放從源表中提取的資料

create multiset volatile table new;

4、建立暫時增量表用於存放增量資料,這裡會存放源系統物理刪除的資料並使用min_date進行標識

create multiset volatile table inc;

5、依據一定的規則向暫時表中載入源表資料,依據需求而定

insert into new select ... from  *** where ...;

6、用暫時表的資料與倉庫表資料作對照。將新增和更改的資料存入增量表中

insert into inc select ... from new where .. not in ..;

7、用倉庫表的有效資料主鍵跟暫時表資料主鍵作對照 in 倉庫表 not in 暫時表的即為源系統物理刪除的字段。將其end_dt用min_date標識存入增量表(這條資料**於倉庫)

insert into .. select ... from where end_dt=$max_date and etl_job_num=920 and (agt_num,agt_modif_num) not in (select agt_num,agt_modif_num from new)

8、對全部在增量表的而且是有效的資料進行關鏈處理

update *** set end_dt=$tx_date where ...;

9、對全部處於增量表中的而且end_dt標識不是min_date的資料進行拉新鏈處理

insert into *** select ... from inc where end_dt <> $min_date;

五、0616(經濟型歷史拉鍊演算法)

1、設定事無級別為ru優先於其它事務

set session characteristics as transaction isolation level ru

2、建立暫時表用於存放從源表中提取的資料

create multiset volatile table new

3、建立增量表用於存放增量資料 這裡僅僅會存放新增個更改的資料

create multiset volatile table inc

4、建立刪除表用於存放邏輯刪除資料 帶有特殊標識的邏輯刪除資料

create multiset volatile table del

5、向暫時表中插入資料依照一定的載入規則

insert into new 

6、用暫時表的資料與倉庫表資料作對照將新增的更改的資料存入增量表中

insert into inc select ... from new 

7、將源表資料中有特殊標識的(一般為end_dt=min_date)存入刪除表中

insert into del select .. from new where end_dt=min_date

8、對全部在增量表和刪除表中資料進行關鏈處理

update *** set end_dt=$tx_date where ...

9、對全部在增量表中的資料拉新鏈除了指定項

insert into *** select ... from inc where seq_num <>''

六、0613(邏輯刪除的歷史拉鍊演算法)

0613和0616差點兒一樣,除了最後一步

9、對全部在增量表中的資料拉新鏈

ETL拉鍊演算法彙總大全

拉鍊演算法總結大全 一 0610演算法 追加 1 刪除倉庫表的載入日期是本次載入日期的資料,以支援重跑 delete from where start dt tx date 2 建立臨時表,用於存放從源表中提取的資料 create multiset volatile table 3 向臨時表中插入資...

ETL拉鍊演算法簡介

1.拉鍊表時針對資料倉儲設計中表儲存資料的方式而定義的,即記錄歷史,記錄乙個事務從開始,一直到當 前狀態的所有變化的資訊 2.拉鍊表的資料可分為 保持不變的資料,insert的資料,delete的資料,updated的資料 拉鍊表的操作可分為 無變化,新開鏈以結束日期為最大日期 有效日期 關鏈 結束...

資料倉儲ETL演算法之拉鍊演算法

目錄 拉鍊定義 拉鍊表資料儲存方式 拉鍊的意義 拉鍊演算法詳解 歷史儲存資料的倆種方式 下面用一組業務資料來解釋倆者區別 業務系統2014年1月1日的資料 賬戶id 戶名餘額 001張三 2000 業務系統2014年1月15日的資料 賬戶id 戶名餘額 001張三 2000 業務系統2014年2月1...