成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

Oracle Insert和bulk Insert測速對比實(shí)例

數(shù)據(jù)庫 Oracle
經(jīng)過長時間接觸Oracle Insert和bulk Insert,我對比了一下他們的執(zhí)行效率。在這里和大家分享一下,希望你看完本文后有不少收獲。

經(jīng)過長時間接觸Oracle Insert和bulk Insert,我對比了一下他們的執(zhí)行效率。在這里和大家分享一下,希望你看完本文后有不少收獲。

測試java的insert 同使用9i以后的bulk Insert 的速度,結(jié)果顯示通過bulk Insert 速度相當(dāng)?shù)目?

100000條記錄

insert ,---------------93秒

bulk Insert -------------0.441秒

環(huán)境:

oracle 10.2.0.3 Windows 2000Server

java

代碼:

  1. SQL> desc a  
  2. Name Type Nullable Default Comments   
  3. ---- ------------ -------- ------- --------   
  4. ID INTEGER Y   
  5. NAME VARCHAR2(20) Y   

bulk Insert 使用的類型及過程

  1. create or replace type i_table is table of number(10);  
  2. create or replace type v_table is table of varchar2(10);  
  3. create or replace procedure pro_forall_insert(v_1 i_table,v_2 v_table)  
  4. as  
  5. c integer;  
  6. begin  
  7. forall i in 1.. v_1.count   
  8. insert into a values(v_1(i),v_2(i));  
  9. end;  
  10.  

測試的java代碼:

  1. import java.io.*;  
  2. import java.sql.*;  
  3. import java.util.*;  
  4. import javax.naming.Context;  
  5. import javax.naming.InitialContext;  
  6. import javax.naming.*;  
  7. import oracle.jdbc.OracleTypes;  
  8. import oracle.sql.*;  
  9. import oracle.sql.ARRAY;  
  10. import oracle.sql.ArrayDescriptor;  
  11. import oracle.sql.STRUCT;  
  12. import oracle.sql.StructDescriptor;  
  13. import java.sql.Connection;  
  14. import java.sql.DriverManager;  
  15. import oracle.jdbc.OracleCallableStatement;  
  16.  
  17. public class testOracle {  
  18. public testOracle() {  
  19. Connection oraCon = null;  
  20. PreparedStatement ps = null;  
  21. Statement st = null;  
  22. ResultSet rs = null;  
  23. try {  
  24. try {  
  25. Class.forName("oracle.jdbc.driver.OracleDriver");  
  26. } catch (ClassNotFoundException ex) {}  
  27. oraCon = DriverManager.getConnection("jdbc:oracle:thin:@192.168.15.234:1521:ora10g", "imcs","imcs");  
  28. oraCon.setAutoCommit(false);  
  29. } catch (SQLException ex) {  
  30. ex.printStackTrace();  
  31. }  
  32. CallableStatement cstmt = null;  
  33. oracle.sql.ArrayDescriptor a = null;  
  34. oracle.sql.ArrayDescriptor b = null;  
  35. if (1 == 1 )  
  36. {  
  37. Object[] s1 = new Object[100000];  
  38. Object[] s2 = new Object[100000];  
  39. for (int i = 0; i < 100000; i++) {  
  40. s1[i] = new Integer(1);  
  41. s2[i] = new String("aaa").concat(String.valueOf(i));  
  42. }  
  43. try {  
  44. a = oracle.sql.ArrayDescriptor.createDescriptor("I_TABLE", oraCon);  
  45. b = oracle.sql.ArrayDescriptor.createDescriptor("V_TABLE", oraCon);  
  46. ARRAY a_test = new ARRAY(a, oraCon, s1);  
  47. ARRAY b_test = new ARRAY(b, oraCon, s2);  
  48. cstmt = oraCon.prepareCall("{ call pro_forall_insert(?,?) }");  
  49. cstmt.setObject(1, a_test);  
  50. cstmt.setObject(2, b_test);  
  51. long aaaa = System.currentTimeMillis();  
  52. System.out.println(System.currentTimeMillis());  
  53. cstmt.execute();  
  54. oraCon.commit();  
  55. System.out.println(System.currentTimeMillis()-aaaa);  
  56.  catch (Exception e) {  
  57. e.printStackTrace();  
  58. }  
  59. }  
  60. else  
  61. {  
  62. try  
  63. {  
  64. PreparedStatement oraPs = null;  
  65. String oraInsertSql =  
  66. "insert into a values(?,?)";  
  67. oraPs = oraCon.prepareStatement(oraInsertSql);  
  68. long aaaa = System.currentTimeMillis();  
  69. System.out.println(System.currentTimeMillis());  
  70. for (int i = 0; i < 100000; i++)  
  71. {  
  72. oraPs.setInt(1,i);  
  73. oraPs.setString(2, new String("aaa").concat(String.valueOf(i)));  
  74. oraPs.executeUpdate();   
  75. }  
  76. oraCon.commit();  
  77. System.out.println(System.currentTimeMillis()-aaaa);  
  78. }  
  79. catch (SQLException ex)  
  80. {  
  81. System.out.print("dddddd");  
  82. System.out.print(ex.getMessage());  
  83. }  
  84. }  
  85. try {  
  86. jbInit();  
  87. } catch (Exception ex) {  
  88. ex.printStackTrace();  
  89. }  
  90. }  
  91. public static void main(String args[]) {  
  92. testOracle a = new testOracle();  
  93. }  
  94. private void jbInit() throws Exception {  
  95. }  
  96. };  
  97.  

【編輯推薦】

  1. 修改Oracle存 儲過程所需代碼
  2. 對Oracle存儲過程的總結(jié)
  3. 實(shí)現(xiàn)Oracle存 儲過程的實(shí)際應(yīng)用的代碼 
  4. 深入高性能的 Oracle動態(tài)SQL開發(fā) 
  5. Oracle SQL的 優(yōu)化規(guī)則解析 
責(zé)任編輯:佚名
相關(guān)推薦

2011-08-11 10:16:15

2010-04-13 14:00:00

Oracle inse

2010-11-18 17:24:27

Oracle旋轉(zhuǎn)ins

2011-08-24 15:48:38

INSERT中文man

2010-05-10 18:30:31

Oracle多表創(chuàng)建

2023-03-27 08:17:48

2010-09-03 15:27:02

SQLSELECT語句

2022-06-27 07:56:36

Mybatis源碼Spring

2010-05-20 08:47:21

MySQL數(shù)據(jù)庫

2010-09-25 14:02:18

SQL INSERT

2018-08-23 09:10:01

數(shù)據(jù)庫MySQLInnoDB

2018-08-27 07:29:34

InnoDBinsertselect

2010-05-27 14:47:14

MySQL INSER

2010-10-08 14:32:47

MySQL使用INSE

2011-07-28 09:08:14

MongoDB性能測試

2010-09-07 13:50:41

SQL語句

2022-05-16 08:03:12

MySQL數(shù)據(jù)庫

2010-09-07 16:31:17

SQL語句insert

2011-03-29 10:47:49

ORACLE數(shù)據(jù)庫

2021-11-11 13:05:25

MySQLINSERT
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號

主站蜘蛛池模板: 韩日av在线 | 久久免费国产视频 | 久草成人 | 视频一区二区三区中文字幕 | 亚洲狠狠爱| 成人免费一区二区三区视频网站 | 成人性视频免费网站 | 国产精品一区久久久久 | 一区二区三区视频在线观看 | 视频三区 | 久久专区 | 欧美激情久久久 | 国产91精品久久久久久久网曝门 | 久久精品一区二 | 精品久久久久久亚洲综合网 | 欧美日韩在线一区二区三区 | 久热久热 | 国产精品99久久久久久久久 | 成年人在线观看 | 一本综合久久 | 爱爱免费视频网站 | 天天插天天操 | 久久久噜噜噜久久中文字幕色伊伊 | www一级片| 亚洲欧美自拍偷拍视频 | 色综合久久天天综合网 | 日本三级网 | 中文字幕亚洲一区二区三区 | 亚洲精品国产第一综合99久久 | 国产精品久久久久久久久图文区 | 欧美极品在线视频 | 一道本一区二区 | 亚洲视频中文字幕 | 久久一区 | 亚洲国产一区二区三区在线观看 | 天堂久久天堂综合色 | av中文字幕在线 | 羞羞的视频免费在线观看 | 欧美不卡一区二区三区 | 干干干操操操 | 爱草视频 |