1.專案中用的是mybatis框架,插入1500條資料,是遍歷list,1500次呼叫 ,這樣效能很差,要等9秒左右。因為1500次呼叫,需要commint1500次,這樣時間嚴重浪費呀!
2.所以,想到批量插入。以下是針對oracle的寫法,資料庫 不同,寫法不一樣的哦,這點需要注意以下
insert into xtgl_role_privs(recid,role_id,menu_id,create_people,create_time,modify_people,modify_time)
select seq_xtgl_role_privs.nextval, a.* from (
select # as role_id,
# as menu_id,
# as create_people,
sysdate as create_time,
'' as modify_people,
'' as modify_time from dual
)a
Mybatis Oracle批量插入資料
專案中會遇到這樣的情況,查詢出多條記錄 乙個list物件集合 一次性要插入多條資料到資料庫中。一般有兩種方式可以解決 缺點 資料多的時候效率太慢,不建議使用 mybatis本身是很靈活的,因為可以自己在xml檔案中編寫sql進行操作,那就可以一次性將插入到資料庫中,這樣只用向資料庫提交一次,效能也可...
Mybatis Oracle批量插入問題記錄
重點 oracle不支援insert into table values 這種語法。因此,我們可以考慮以下兩種方式實現批量插入 1 多條insert into語句 但是效率比較低 insert into table bean.a,bean.b values 備註 jdbctype integer 指...
mybatis批量查詢,批量新增,批量更新
一 多條件批量查詢 先上 再講解 select from ifs company where id and code id標籤不用多說,和dao方法一一對應。parametertype標籤寫list就可以,如果是其他型別對應寫就可以。resultmap,自己定義的字段實體類對應。二 批量新增 先上 ...