建表语句以及测试数据如下:
CREATE TABLE `test_t1` (
`start_time` DATE NULL ,
`end_time` DATE NULL DEFAULT "9999-12-31",
`id_org` VARCHAR(32) NOT NULL ,
`pmis_code` VARCHAR(64) NOT NULL ,
`point_name` VARCHAR(128) NULL ,
`name_org` VARCHAR(128) NULL ,
`point_id` VARCHAR(255) NULL ,
`data_type` VARCHAR(255) NULL ,
`source` VARCHAR(255) NULL ,
`org_code` VARCHAR(4) NULL ,
`ppis_code` VARCHAR(32) NULL ,
`company_code` VARCHAR(32) NULL ,
`company_name` VARCHAR(128) NULL ,
`site_code` VARCHAR(4) NULL ,
`site_name` VARCHAR(32) NULL ,
`main_system_code` VARCHAR(8) NULL ,
`main_system_name` VARCHAR(64) NULL ,
`sub_system_code` VARCHAR(8) NULL ,
`sub_system_name` VARCHAR(64) NULL ,
`unit_code` VARCHAR(8) NULL ,
`unit_name` VARCHAR(64) NULL ,
`components_code` VARCHAR(8) NULL ,
`components_name` VARCHAR(64) NULL ,
`monitor_code` VARCHAR(16) NULL ,
`monitor_name` VARCHAR(64) NULL ,
`ext_serial_dec` VARCHAR(128) NULL ,
`ext_serialnum` VARCHAR(3) NULL ,
`ext_source` VARCHAR(3) NULL ,
`ext_mon_type` VARCHAR(1) NULL ,
`ext_data_type` VARCHAR(1) NULL ,
`editor` VARCHAR(8) NULL ,
`load_date` DATETIME NULL DEFAULT CURRENT_TIMESTAMP COMMENT '录入时间'
) ENGINE=OLAP
UNIQUE KEY(`start_time`, `end_time`, `id_org`, `pmis_code`)
COMMENT 'test'
DISTRIBUTED BY HASH(`pmis_code`) BUCKETS 1
;
INSERT INTO test_t1 (start_time, end_time, id_org, pmis_code, point_name, name_org, point_id, data_type, source, org_code, ppis_code,
company_code, company_name, site_code, site_name, main_system_code, main_system_name,
sub_system_code, sub_system_name, unit_code, unit_name, components_code, components_name, monitor_code,
monitor_name, ext_serial_dec, ext_serialnum, ext_source, ext_mon_type, ext_data_type, editor, load_date)
VALUES ('2024-01-01', '9999-12-31', '12', '1.2.3.4', '测试', '测试数据', '', '', '', '1122', 'ss', 'aa',
'test', 'tt', 'tt', '', '', '', '', '', '', '', '', '12', 'aa', 'ss', '001', '002', 'A',
'P', '', '');
select * from test_t1;
此时数据正常,查询结果如下:
当我针对 point_id,data_type,source 三个字段进行更新操作的时候,执行如下sql语句:
UPDATE test_t1 set point_id='100' and data_type='33' and source='kafka' where pmis_code='1.2.3.4';
语句顺利执行完成,并没有报错信息,执行完成后查看表数据结果如下:
进行更新操作后,point_id字段被更新,但是更新的值为0,不是我指定的100,另外两个值没有发生任何改变,执行了update的结果并不是我预想中的结果