[英]Unidac / MyDac / SQL - I have problem with fast insert about 1000 rows
I use unidac components.我使用 unidac 组件。 And i have problem with fast insert about 1000 rows.
我在快速插入大约 1000 行时遇到问题。
var
query: TUniquery;
begin
query.SQL.Add('INSERT INTO Table (field1,field2,field3) VALUES (:b0,:b1,:b2);');
for I := 0 to 1000 do
begin
Query.ParamByName('b0').AsInteger := 1;
Query.ParamByName('b1').AsInteger := 2;
Query.ParamByName('b2').AsInteger := Random(100);
Query.Prepare;
Query.Execute; //1000 times is very slow
end;
It is faster它更快
var
query: TUniquery;
begin
for I := 0 to 1000 do
Query.SQL.Add('INSERT INTO Table (field1,field2,field3) VALUES (1,2,Random(100));');
end;
Query.Execute; //1 times - is fast add
end;
But, I would like to use the first format with the procedure Query.ParamByName('b1').AsInteger:= 2;但是,我想在过程Query.ParamByName('b1').AsInteger:= 2;中使用第一种格式。 because it is clearer and with a large number of columns I find myself easier to find.
因为它更清晰并且有大量的列,所以我发现自己更容易找到。
Do you have any ideas on how to solve this?你对如何解决这个问题有什么想法吗?
Maybe you have some other ways to quickly insert a large number of rows with different data?也许您还有其他一些方法可以快速插入大量具有不同数据的行?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.