oracle批量insert很慢,Oracle批量插入数据用Varry,效率很低。

  • Post author:
  • Post category:其他

public static String Procedure_Ins_path(){

String dir = “e:\\”;

IndexProcesser p;

p = new IndexProcesser();

p.searchDirectorys(dir,true);

String s0 =”DROP SEQUENCE  SEQ_pid;” +

” CREATE SEQUENCE  SEQ_pid INCREMENT BY 1 START WITH 1 NOCYCLE; “;

String s1 = “declare ” +

“type path_varray is varray(2000) of varchar2(200); ” +

“p_v path_varray:=path_varray (“;

String s3 =  “); begin ” +

“for i in 1..2000 loop ” +

“if p_v(i) = ‘null’ then ” +

“p_v(i):=’null’; ” +

“else ” +

“INSERT INTO tb_allpath (ID ,path) VALUES (SEQ_PID.NEXTVAL,p_v(i));”+

“end if; ” +

“end loop;” +

“commit;” +

“end;”;

String s2 =””;

for(int i = 0;i<1999;i++)

s2 = s2+”‘”+p.Directorys[i]+”‘,”;

s2 = s2 +”‘”+ p.Directorys[1999]+”‘”;

return s1+s2+s3;

}