Oracle預存程序中暫存資料表的提示

來源:互聯網
上載者:User

標籤:

一、Oracle暫存資料表知識   

在Oracle中,暫存資料表分為SESSION(會話級)、TRANSACTION(事務級)兩種,SESSION級的暫存資料表資料在整個SESSION都存在,直到結束此次SESSION;而 TRANSACTION級的暫存資料表資料在TRANACTION結束後消失,即COMMIT/ROLLBACK或結束SESSION都會清除 TRANACTION暫存資料表資料。

1) 會話級暫存資料表 樣本

    1建立

    create global temporary table temp_tbl(col_a varchar2(30))

    on commit preserve rows

2插入資料

    insert into temp_tbl values(‘test session table‘)

    3提交

    commit;

    4查詢

    select *from temp_tbl

可以看到資料‘test session table‘記錄還在。

結束SESSION,重新登入,再查詢資料select *from temp_tbl,這時候記錄已不存在,因為系統在結束SESSION時自動清除記錄 。

2) 事務級暫存資料表 樣本

    1建立

    create global temporary table temp_tbl(col_a varchar2(30))

    on commit delete rows

    2插入資料

    insert into temp_tbl values(‘test transaction table‘)

   3提交

   commit ;

   4查詢

   select *from temp_tbl

這時候可以看到剛才插入的記錄‘test transaction table‘已不存在了,因為提交時已經晴空了資料庫;同樣,如果不提交而直接結束SESSION,重新登入記錄也不存在 。

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.