开发者

Inserting millions of records in table

开发者 https://www.devze.com 2023-03-25 03:01 出处:网络
what is the best way to insert millions of records into table. Some approaches are: 1) writing jdbc program to insert data.

what is the best way to insert millions of records into table.

Some approaches are:

1) writing jdbc program to insert data.

2) writing pl/sql procedure to insert data.

can any one please sugges开发者_开发问答t other approaches and best as well.


I would suggest that you should use the Data Migration tool that comes with most of the databases like MS Sql Server.

Otherwise JDBC/PL-SQL will behave same, But Its better to run all the queries in a Transaction and PL-SQL will have a bit better hand on managing Transaction.

But In Java you can read the source a bit efficiently then PL-SQL (if it is possible) like if you have a source of XML, CSV file etc.


You can also do a batch insert in JDBC (if your JDBC driver is 2.0 and higher).


I assume it is mysql:

INSERT INTO x (a,b)
VALUES 
 ('1', 'one'),
 ('2', 'two'),
 ('3', 'three')

If it is one time only issue, I dont think java should be involoved.

I suggest you tell us where do you take your data from?


PL/SQL procedure will let you handle transactions effectively. It also depends on where are you going to read the data from? Not that PLSQL can't do some stuff but Java might be better at it.


Batch processing with JDBC API will do the job for such huge no of records.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号