MSSQL、ORALCE批量新增,后者太强

时间:2021-06-18 17:17:25

MSSQL:131072条数据,7秒。
代码:

CREATE TABLE tempTable(bigint varchar(30),item_name varchar(30)); 
INSERT INTO tempTable VALUES (1, 'Hammer')
DECLARE @counter int;
SET @counter = 1 ;
WHILE(@counter <= 17)
BEGIN
INSERT INTO tempTable (bigint, item_name)
(SELECT bigint + (SELECT COUNT(*) FROM tempTable), 'Hammer' FROM tempTable)
SET @counter = @counter + 1
END
SELECT * FROM tempTable
--DROP TABLE tempTable

结果:
MSSQL、ORALCE批量新增,后者太强

ORACLE:131072条数据,0.469秒。
代码:

CREATE TABLE tempTable(bigint varchar(30),item_name varchar(30)); 
INSERT INTO tempTable VALUES (1, 'Hammer')
CREATE OR REPLACE PROCEDURE testbatch is
begin

for i in 1 .. 17 loop

INSERT INTO tempTable
(bigint, item_name)
(SELECT bigint + (SELECT COUNT(*) FROM tempTable), 'Hammer'
FROM tempTable);


end loop;
commit;
end testbatch;

结果:
MSSQL、ORALCE批量新增,后者太强