錯(cuò)誤的flink-cdc語句sql
CREATE TABLE t_wx_source_1 (
id String,
name String,
age String
) WITH (
'connector' = 'oracle-cdc',
'hostname' = '192.168.1.135',
'port' = '1521',
'username' = 'flink',
'password' = 'XXXXX',
'database-name' = 'dbc',
'schema-name' = 'FLINK',
'table-name' = 't_wx_source_2'
);
CREATE TABLE t_wx_target (
id String Not Null,
name String,
age String,
PRIMARY KEY(id) NOT ENFORCED
) WITH (
'connector' = 'jdbc',
'url' = 'jdbc:mysql://192.168.1.91:3306/test',
'table-name' = 't_wx_target_1',
'username' = 'root',
'password' = 'XXXXX',
'driver' = 'com.mysql.cj.jdbc.Driver'
);
insert into t_wx_target select id,name,age from t_wx_source_1;
我們看一下oracle的數(shù)據(jù)庫字段
再看一下錯(cuò)誤sql里面的內(nèi)容
flink報(bào)錯(cuò)內(nèi)容
Column ‘id’ is NOT NULL, however, a null value is being written into it. You can set job configuration ‘table.exec.sink.not-null-enforcer’=‘DROP’ to suppress this exception and drop such records silently
大致意思就是不能插入為空的數(shù)值。
為什么會(huì)報(bào)這個(gè)錯(cuò)誤,我們來看DML的執(zhí)行語句:
insert into t_wx_target select id,name,age from t_wx_source_1;文章來源:http://www.zghlxwxcb.cn/news/detail-521224.html
每次數(shù)據(jù)都是null,然后我們的sink(t_wx_target )表里面的字段id,是非空字段,所以就報(bào)錯(cuò)了文章來源地址http://www.zghlxwxcb.cn/news/detail-521224.html
正確的sql
CREATE TABLE t_wx_source_1 (
id String NOT NULL,
name String,
age String
) WITH (
'connector' = 'oracle-cdc',
'hostname' = '192.168.1.135',
'port' = '1521',
'username' = 'flink',
'password' = 'XXXX',
'database-name' = 'dbc',
'schema-name' = 'FLINK',
'table-name' = 't_wx_source_2'
);
CREATE TABLE t_wx_target (
id String,
name String,
age String,
PRIMARY KEY(id) NOT ENFORCED
) WITH (
'connector' = 'jdbc',
'url' = 'jdbc:mysql://192.168.1.91:3306/test',
'table-name' = 't_wx_target_1',
'username' = 'root',
'password' = 'XXXXXX',
'driver' = 'com.mysql.cj.jdbc.Driver'
);
insert into t_wx_target select id,name,age from t_wx_source_1;
三級(jí)目錄
到了這里,關(guān)于【現(xiàn)場問題】flink-cdc,Oracle2Mysql的坑,Oracle區(qū)分大小寫導(dǎo)致的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!