mybatis中批量增、删、改的SQL语句

1.批量增

  
    insert into SYS_DEPT ( 
    DEPT_ID, ORG_ID, DEPT_NAME, LEADER, IS_USED, REMARK, 
      ENTRY_PROGRAM,ENTRY_USER, MODIFY_DATE, MODIFY_PROGRAM, MODIFY_USER
      ) 
    
     select 
     #{dept.deptId,jdbcType=VARCHAR}, #{dept.orgId,jdbcType=VARCHAR}, #{dept.deptName,jdbcType=VARCHAR}, 
         #{dept.leader,jdbcType=VARCHAR}, #{dept.isUsed,jdbcType=DECIMAL}, #{dept.remark,jdbcType=VARCHAR}, 
         #{dept.entryProgram,jdbcType=VARCHAR}, #{dept.entryUser,jdbcType=VARCHAR}, 
         #{dept.modifyDate,jdbcType=DATE}, #{dept.modifyProgram,jdbcType=VARCHAR}, #{dept.modifyUser,jdbcType=VARCHAR}
         from dual
    
  

2.批量删

  <delete id="deleteBatch" parameterType="java.util.List">
    delete from SYS_DEPT
    where DEPT_ID IN
    "list" item="sd" index="index" open="(" separator="," close=")">
        #{sd.deptId,jdbcType=VARCHAR}
    
  delete>

3.批量改

  "updateBatch" parameterType ="java.util.List">
    <foreach collection="list" item="user" index="index" open="begin" separator=";" close=";end;">
      update SYS_USER 
      set IS_USED = #{user.isUsed}
      where USER_ID = #{user.userId}
    foreach>
  

你可能感兴趣的:(mybatis中批量增、删、改的SQL语句)