Oracle遊標進行迴圈效率比較

來源:互聯網
上載者:User

標籤:read   rom   use   desc   分類   end   多個   insert   gpo   

對300萬一張表資料,用遊標進行迴圈,不同寫法的效率比較對300萬一張表資料,用遊標進行迴圈,不同寫法的效率比較 1、顯示遊標 declare    cursor cur_2 is select a.cust_name from ea_cust.cust_info a;    cust_id varchar2(100);    begin    open cur_2;    loop        fetch cur_2 into cust_id;        exit when cur_2%notfound;        NULL;    end loop;    close cur_2;end; --耗時48秒 2、隱式遊標 declare    begin    for cur_2 in (select c.cust_name from ea_cust.cust_info c) loop           NULL;         end loop; end; --耗時16秒 3、bulk collect into + cursor declare    cursor cur_3 is select a.cust_name from ea_cust.cust_info a;    type t_table is table of varchar2(100);    c_table t_table;    to_cust_id varchar2(100); begin    open cur_3;    loop         fetch cur_3 bulk collect into c_table limit 100;         exit when c_table.count = 0;         for i in c_table.first..c_table.last loop             null;                      end loop;             end loop;    commit;end; --耗時13秒,看樣子這種最快 Oracle對300萬一張表資料,用遊標進行迴圈,不同寫法的效率比較摘要: 對300萬一張表資料,用遊標進行迴圈,不同寫法的效率比較1、顯示遊標declare cursor cur_2 is select a.cust_name from ea_cust.cust_info a; cust_id varchar2(100); begin open cur_2; loop fetch cur_2 into cust_id; exit when cur_2%notfound; NULL; end loop; close cur_2;end;--耗時48秒2、隱式遊標declare begin for cur_2 in (select c.c...閱讀全文

posted @ 2013-01-06 18:12 Code changes life 閱讀(563) | 評論 (0) 編輯

oracle行列轉換摘要: Oracle 行列轉換1、固定列數的行列轉換如student subject grade--------- ---------- --------student1 語文 80student1 數學 70student1 英語 60student2 語文 90student2 數學 80student2 英語 100……轉換為語文 數學 英語student1 80 70 60student2 90 80 100……語句如下:select student,sum(decode(subject,‘語文‘, grade,null)) "語文",sum(decode(閱讀全文

posted @ 2013-01-06 16:38 Code changes life 閱讀(334) | 評論 (0) 編輯

資料庫關聯映射建表圖示摘要: ~總結一下資料庫的 一對多、多對一、一對一、多對多 關係 以及對應的建表方式~關聯映射:一對多/多對一存在最普遍的映射關係,簡單來講就如球員與球隊的關係;一對多:從球隊角度來說一個球隊擁有多個球員 即為一對多多對一:從球員角度來說多個球員屬於一個球隊 即為多對一資料表間一對多關聯性如:關聯映射:一對一一對一關聯性就如球隊與球隊所在地址之間的關係,一支球隊僅有一個地址,而一個地址區也僅有一支球隊。資料表間一對一關聯性的表現有兩種,一種是外部索引鍵關聯,一種是主鍵關聯。圖示如下:一對一外部索引鍵關聯:一對一主鍵關聯:要求兩個表的主鍵必須完全一致,通過兩個表的主鍵建立關聯關係關聯映射:多對多多對多關係也很常見,例閱讀全文

posted @ 2013-01-04 17:01 Code changes life 閱讀(153) | 評論 (0) 編輯

Oracle中查詢正鎖表的使用者及釋放被鎖的表的方法摘要: 查詢oracle鎖定的表及殺掉鎖表的進程,注意查看的時候要用sys/sys 管理員的身份登入1、首先查看鎖定的表太進程:SELECT substr(v$lock.sid,1,4) "SID", serial#, V$SESSION.sid, substr(username,1,12) "UserName", substr(object_name,1,25) "ObjectName", v$lock.type "LockType", www.2cto.com decode(rtrim(substr(lmode,1,4閱讀全文

posted @ 2012-12-27 14:43 Code changes life 閱讀(1551) | 評論 (0) 編輯

oracle小常識摘要: 一、oracle時間類型的處理1、用sql語句把時間 2010-10-01 09:28:03插入oracle 的date類型欄位insert into 表名(欄位名) values (to_date(‘2010-10-01 09:28:03‘,‘yyyy-mm-dd hh24:mi:ss‘))2、根據date類型欄位查詢select * from 表名 where to_char(date類型欄位,‘yyyy-mm-dd‘) between ‘2012-03-06‘ and ‘2012-03-08‘二、delete閱讀全文

posted @ 2012-03-08 09:13 Code changes life 閱讀(106) | 評論 (0) 編輯

分類: Oracle

Oracle遊標進行迴圈效率比較

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.