时序数据库Tdengine 批量插入避免因为主键ts时间重复导致数据被覆盖掉
·
目录
使用now() + #{index}a 其中那这个 #{index}是<foreach>标签里的循环出来的index
在Mybatis中使用
<insert id="batchInsert" parameterType="java.util.List">
insert into uri
(
id,
name,
uri,
code,
property_id,
ts
)
values
<foreach collection="uriList" item="uri" separator="," index="index">
(
#{uri.id},
#{uri.name},
#{uri.uri},
#{uri.code},
#{uri.propertyId},
now() + #{index}a
)
</foreach>
</insert>
在数据库管理工具中使用 now+100a 其中a 代表毫秒 100a就是100毫秒
INSERT INTO uri (
ts,
id,
name,
uri,
code,
property_id)
VALUES (
now+100a,
'erweersdfsds',
'P2',
'A2',
'P2',
'gtyja678-gty7-yui9-889o-11123ef9iuo0');
DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。
更多推荐

所有评论(0)