首页 > 开发 > 综合 > 正文

SQL-一条SQL插入多条数据

2024-07-21 02:52:46
字体:
来源:转载
供稿:网友

MySQL

insert into persons (id_p, lastname , firstName, city )values(200,'haha' , 'deng' , 'shenzhen'),(201,'haha2' , 'deng' , 'GD'),(202,'haha3' , 'deng' , 'Beijing');

Oracle

insert allinto RAW_AMORT_SCHEDULE (BOND_CODE,AMORTIZE_DATE,AMORTIZE_TYPE,AMORTIZE_RATE,REMARKS) values('1','1','1','1','1')into RAW_AMORT_SCHEDULE (BOND_CODE,AMORTIZE_DATE,AMORTIZE_TYPE,AMORTIZE_RATE,REMARKS) values('2','2','2','2','2')into RAW_AMORT_SCHEDULE (BOND_CODE,AMORTIZE_DATE,AMORTIZE_TYPE,AMORTIZE_RATE,REMARKS) values('3','4','4','4','3')SELECT 1 FROM DUAL

在mybatis中应该这样使用

<insert id="insertRecordBatch" parameterType="java.util.List"> insert all <foreach collection="list" item="item" index="index" separator=" " > into RAW_AMORT_SCHEDULE(BOND_CODE,AMORTIZE_DATE,AMORTIZE_TYPE,AMORTIZE_RATE,REMARKS) values (#{item.bondCode},to_date(#{item.amortizeDate},'YYYYMMDD'),#{item.amortizeType},#{item.amortizeRate},#{item.remarks}) </foreach> SELECT 1 FROM DUAL </insert>
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表