问题是什么
数据库报错 Error 1366 (HY000): Incorrect string value
具体情况复现
插入语句
insert ignore into user(
name,
disc_content
)
select
t1.name,
group_concat(
concat('{"评论人":"', t1.author, '","解决人":"', t1.resolved_name, '","评论时间":"', t1.note_time, '","评论内容":"', t1.body, '"}')
) as disc_content,
from
date_detail as t1
group by user_id
出现错误原因
concat()
函数默认1024字节,超过1024,可能导致数据截断。从而使出现一些OceanBase不能插入的字符(mysql并不会出现同样原因)
解决方案
使用json_object()
函数替换
insert ignore into user(
name,
disc_content
)
select
t1.name,
json_arrayagg(
json_object(
'评论人', t1.author,
'解决人', t1.resolved_name,
'评论时间', t1.note_time,
'评论内容', t1.body
)
) as disc_content,
from
date_detail as t1
group by user_id
2023-12-02 18:16:11 星期六
标签:一次,name,OceanBase,t1,content,排查,disc,评论,user From: https://www.cnblogs.com/dongzhiwei/p/17871971.html