mybatis oracle 批量新增
时间:2021-07-01 10:21:17
帮助过:12人阅读
table u_info{
id NUMBER not null,
info_no VARCHAR2(
32)
not null,
name VARCHAR2(
32)
not null,
birthday DATE,
age NUMBER,
create_date DATE not null
}
-- 自动按天数分区
-- tablespace TBS_DATA
--partition by range (create_date) interval (numtodsinterval(1, ‘DAY‘))
--(partition P20190101 values less than (TO_DATE(‘2019-01-01 00:00:00‘, ‘SYYYY-MM-DD HH24:MI:SS‘, ‘NLS_CALENDAR=GREGORIAN‘)))
;
--create unique index IU_INFO_NO_DATE on u_info (info_no,create_date) tablespace TBS_IDX online local;
-- Add comments
comment
on table u_info
is ‘用户信息表‘;
comment on column u_info.id
is ‘主键‘;
comment on column u_info.info_no
is ‘用户编号‘;
comment on column u_info.name
is ‘姓名‘;
comment on column u_info.birthday
is ‘生日‘;
comment on column u_info.age
is ‘年龄‘;
comment on column u_info.create_date
is ‘创建时间‘;
二、mybatis xml(传入集合参数,建议批量数量控制在3000以内)
<insert id="insertBatch" parameterType="java.util.List">
/**UserInfoMapper.insertBatch*/
INSERT INTO u_info(
id,
info_no,
name,
birthday,
age,
create_date
)
SELECT
S.*,
SYSDATE
FROM(
<foreach item="bean" index="index" collection="list" separator="UNION ALL">
SELECT
#{bean.id, jdbcType=DECIMAL},
#{bean.infoNo, jdbcType=VARCHAR},
#{bean.name, jdbcType=VARCHAR},
#{bean.birthday, jdbcType=TIMESTAMP},
#{bean.age, jdbcType=DECIMAL}
FROM DUAL
</foreach>
) S
</insert>
mybatis oracle 批量新增
标签:分区 bat XML ESS sda tis arc local gre