Flow概覽
表結構
源表與目標表結構(除了表名都相同)
CREATE TABLE
user_model(
idint unsigned NOT NULL AUTO_INCREMENT,
id_numbervarchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '身份證號',
namevarchar(20) NOT NULL,
phone_numberchar(11) DEFAULT NULL,
addressvarchar(256) DEFAULT NULL,
ageint DEFAULT NULL COMMENT '年齡',
genderint DEFAULT NULL COMMENT '性別',
passwordvarchar(256) DEFAULT NULL,
create_timedatetime DEFAULT NULL,
update_timedatetime DEFAULT NULL,
other_infojson DEFAULT NULL,
basic_infosjson DEFAULT NULL,
deleted tinyint NOT NULL DEFAULT '0', PRIMARY KEY (
id), UNIQUE KEY
uni_id_number (
id_number) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE
user_model_target(
idint unsigned NOT NULL AUTO_INCREMENT,
id_numbervarchar(20) DEFAULT NULL,
namevarchar(20) NOT NULL,
phone_numberchar(11) DEFAULT NULL,
addressvarchar(256) DEFAULT NULL,
ageint DEFAULT NULL COMMENT '年齡',
genderint DEFAULT NULL COMMENT '性別',
passwordvarchar(256) DEFAULT NULL,
create_timedatetime DEFAULT NULL,
update_timedatetime DEFAULT NULL,
other_infojson DEFAULT NULL,
basic_infosjson DEFAULT NULL,
deleted tinyint NOT NULL DEFAULT '0', PRIMARY KEY (
id), UNIQUE KEY
uni_id_number (
id_number) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
前提條件
- 配置了源和目標的MySQL資料來源
- 源表與目標表結構一致
細節說明
GenerateFlowFile 作為流程的觸發點,在這裡我們設定為每5S觸發一次同步.
ExecuteSQL 負責查詢源表資料.
PutDatabaseRecord 負責將資料插入或新增到目標表中.