我想用jdbc插入數據到TERADATA,但速度很慢。我怎樣才能讓它更快?如何批量插入?
我寫了這個代碼:
connection_tera= DriverManager.getConnection
(
"jdbc:teradata://192.168.x.xx/database=DBC,tmode=ANSI,charset=UTF8","dbc","dbc"
);
stmt_tera = connection_tera.prepareStatement("insert into a.b values(?)");
//some code here to start while loop
stmt_tera.setObject(i,reset.getobject(i));
stmt_tera.addBatch();
if(addedBatchNumber%100==0)
stmt_tera.executeBatch();
connection_tera.commit();
stmt_tera.clearBatch();
//some code here and finish while loop
我應該添加paramater像TYPE = FASTLOAD到連接字符串?或者是其他東西?
批量操作通常是在數據庫系統上配置的,但也許在目標表上禁用索引將有所幫助 – 2013-07-03 09:17:48