ARTICLE DETAIL

建站实战干货

来自一线的建站与推广经验沉淀,每一条都经过真实交付验证。

时序数据库Tdengine 批量插入避免因为主键ts时间重复导致数据被覆盖掉

2026/9/13 19:46:52 拓冰建站 浏览量
时序数据库Tdengine 批量插入避免因为主键ts时间重复导致数据被覆盖掉

 

目录

        在Mybatis中使用 

       在数据库管理工具中使用  now+100a


 使用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

INSERT INTO uri (

                  ts,

                  id,

                  name,

                  uri,

                  code,

                  property_id)

VALUES (

               now+100a,

               'erweersdfsds',

               'P2',

               'A2',

              'P2',

              'gtyja678-gty7-yui9-889o-11123ef9iuo0');