ETL 準備資料庫

2021-09-12 23:01:53 字數 3516 閱讀 6703

為了接下去的教程,我們需要先準備資料庫,通過新舊資料庫的遷移,來演示如何使用 pdi 工具。讓我們建立如下資料庫結構:

舊資料庫:

訂單表:

create table `order`  (

`id` int(10) unsigned not null auto_increment,

`code` varchar(40) character set utf8mb4 collate utf8mb4_general_ci not null default '' comment '訂單編碼',

`order_status` tinyint(2) unsigned not null default 1 comment '1待付款 2待發貨 3待收貨 4已收貨 5已取消',

`name` varchar(40) character set utf8mb4 collate utf8mb4_general_ci not null default '',

`phone_number` varchar(45) character set utf8mb4 collate utf8mb4_general_ci null default null,

`status` tinyint(1) unsigned not null default 1 comment '狀態 0刪除 1正常 ',

`created_at` bigint(11) unsigned not null default 0 comment '建立時間',

`updated_at` bigint(11) unsigned not null default 0 comment '更新時間',

primary key (`id`) using btree

) ;

訂單商品表:

create table `order_goods`  (

`id` int(10) unsigned not null auto_increment,

`orders_id` int(10) unsigned not null default 0,

`goods_name` varchar(120) character set utf8mb4 collate utf8mb4_general_ci not null default '' comment '商品名稱',

`goods_num` smallint(5) unsigned not null default 1 comment '購買數量',

`price` decimal(10, 2) not null default 0.00 comment '商品售價',

`status` tinyint(1) unsigned not null default 1 comment '狀態 0刪除 1正常',

`created_at` bigint(11) unsigned not null default 0 comment '建立時間',

`updated_at` bigint(11) unsigned not null default 0 comment '更新時間',

primary key (`id`) using btree

);

新資料庫:

客戶表:

create table `client`  (

`id` int(10) unsigned not null auto_increment,

`name` varchar(40) character set utf8mb4 collate utf8mb4_general_ci not null default '',

`phone_number` varchar(45) character set utf8mb4 collate utf8mb4_general_ci null default null,

`status` tinyint(1) unsigned not null default 1 comment '狀態 0刪除 1正常 ',

`created_at` bigint(11) unsigned not null default 0,

`updated_at` bigint(11) unsigned not null default 0,

primary key (`id`) using btree

);

訂單表:

create table `order`  (

`id` int(10) unsigned not null auto_increment,

`code` varchar(40) character set utf8mb4 collate utf8mb4_general_ci not null default '' comment '訂單編碼',

`order_status` tinyint(2) unsigned not null default 1 comment '1待付款 2待發貨 3待收貨 4已收貨 5已取消',

`client_id` int(10) unsigned not null default 0 comment '使用者id',

`status` tinyint(1) unsigned not null default 1 comment '狀態 0刪除 1正常 ',

`created_at` bigint(11) unsigned not null default 0,

`updated_at` bigint(11) unsigned not null default 0,

primary key (`id`) using btree

)

訂單商品表:

create table `order_goods`  (

`id` int(10) unsigned not null auto_increment,

`orders_id` int(10) unsigned not null default 0,

`goods_name` varchar(120) character set utf8mb4 collate utf8mb4_general_ci not null default '' comment '商品名稱',

`goods_num` smallint(5) unsigned not null default 1 comment '購買數量',

`price` decimal(10, 2) not null default 0.00 comment '商品售價',

`status` tinyint(1) unsigned not null default 1 comment '狀態 0刪除 1正常',

`created_at` bigint(11) unsigned not null default 0 comment '建立時間',

`updated_at` bigint(11) unsigned not null default 0 comment '更新時間',

primary key (`id`) using btree

)

ETL之資料庫

今天剛剛註冊非常激動。今天先分享一下etl是幹什麼的。etl全稱 extraction transformation loading,中文名資料抽取 轉換和載入。etl負責將分布的 異構資料來源中的資料如關係資料 平面資料檔案等抽取到臨時中間層後進行清洗 轉換 整合,最後載入到資料倉儲或資料集市中,...

資料庫準備

1.2.匯入資料庫指令碼 1 執行d trinity source trinitycore sql create create mysql.sql。2 選擇auth資料庫,執行d trinity source trinitycore sql base auth database.sql指令碼。3 選...

資料庫相關 ETL 實習筆記

1 oracle操作 1 插入日期 insert into tablename values to date 2011 1 1 yyyy mm dd 2 將乙個表的資料匯入另乙個表 要求字段個數一致,最好型別也一致 insert into tablename1 select from tablena...