时序数据库Tdengine 批量插入避免因为主键ts时间重复导致数据被覆盖掉
使用now() + #{index}a其中那这个 #{index}是标签里的循环出来的index。
·
目录
使用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');
更多推荐




所有评论(0)