A. java怎么将选中的多行数据插入表中
java 连接数据库时,往数据库一次添加多条数据,可以在 DAO 层,使用
executeBatch0批量插入数据,如下代
码:
conn = DBToolkit .getConnection0;
Statement stmt =
conn . createStatementO ; j //连续添加多条 sql
stmt . addBatch (" insert into testdb . book ( kind , name ) values ( java ', java in j
aciton )");
stmt . addBatc (" insert into testdb . book ( kind , name ) values ( c ',’ c in aciton )");//执行批量执行
stmt .executeBatch0);
B. Oracle数据库,一条SQL语句插入多行数据
按照你现有的表创建历史数据:
createtablekhqfbd_1
(khnint,
khqxhint,
khmcvarchar2(20),
qsrqvarchar2(8),
jsrqvarchar2(8),
bzvarchar2(100));
insertintokhqfbd_1values(2024,1,'第一季度','20240101','20240331','1');
insertintokhqfbd_1values(2024,2,'第二季度','20240401','20240630','1');
insertintokhqfbd_1values(2024,3,'第三季度','20240701','20240930','1');
insertintokhqfbd_1values(2024,4,'第四季度','20241001','20241231','1');
commit;
执行:
declare
v_yearint;
begin
selectmax(khn)intov_yearfromkhqfbd_1;
insertintokhqfbd_1
values
(v_year+1,1,'第一季度',v_year+1||'0101',v_year+1||'0331','1');
insertintokhqfbd_1
values
(v_year+1,2,'第二季度',v_year+1||'0401',v_year+1||'0630','1');
insertintokhqfbd_1
values
(v_year+1,3,'第三季度',v_year+1||'0701',v_year+1||'0930','1');
insertintokhqfbd_1
values
(v_year+1,4,'第四季度',v_year+1||'1001',v_year+1||'1231','1');
commit;
end;
执行后结果:
C. asp.net怎么向数据库插入多行数据
insert into 表 values()
insert into 表 values()