bulk import hilfe

05/12/2015 20:36 xXwaldeXx#1
Hi,
ich möchte in meine Tabelle Email Adressen aus einer Datei importieren, aber hab keine Idee wie ich das machen soll.Bis jetzt hab ich was von "bulk insert" gelesen, weiß jedoch nicht wie ich das anwenden soll oder kann..
Wenn jemand weiß wie man mit Datenbanken also sql-zeug umgeht, kann er mir gerne helfen :D

mfg
05/13/2015 10:19 Lee Ki-Hwan#2
[Only registered and activated users can see links. Click Here To Register...]

In dem Link ist dies zu finden:
Quote:
The Oracle JDBC driver does support bulk inserts. What you can do is that you add all your data to a “batch” and then execute the entire batch. This gives you the advantage that there is only 1 INSERT statement executed which inserts all your data into the table at once! So instead of 10,000 round-trips, I only have 1 sending all the data over in one big chunk:
Code:
conn.prepareStatement("TRUNCATE TABLE testloadtable").execute();
conn.prepareStatement("ALTER SESSION SET SQL_TRACE=TRUE").execute();
 
PreparedStatement stmt = conn.prepareStatement("INSERT /* addBatch insert */ INTO testloadtable (id, text) VALUES (?,?)");
 
for (int i=0;i<10000;i++)
{
  stmt.setInt(1, i);
  stmt.setString(2, "test" + i);
  stmt.addBatch();
}
stmt.executeBatch();
conn.commit();
 
conn.prepareStatement("ALTER SESSION SET SQL_TRACE=FALSE").execute();
Du musst bei jeden Eintrag .addBatch() aufrufen und es dann mit .executeBatch() vollenden.