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()