暫存資料表,oracle暫存資料表

來源:互聯網
上載者:User

暫存資料表,oracle暫存資料表
暫存資料表讓使用者只能夠操作各自的資料中而互不干擾,不用擔心會破壞或影響其他SESSION/TRANSACTION的資料。暫存資料表分為SESSION、TRANSACTION兩種。1. SESSION級的暫存資料表資料在整個SESSION都存在,直到結束此次SESSION;2. TRANSACTION級的暫存資料表資料在TRANACTION結束後消失,即COMMIT/ROLLBACK或結束SESSION都會清除TRANACTION暫存資料表資料。 兩種暫存資料表的文法:create global temporary table 暫存資料表名 on commit preserve|delete rows 用preserve時就是SESSION級的暫存資料表,用delete就是TRANSACTION級的暫存資料表 一、SESSION級暫存資料表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時自動清除記錄 二、TRANSACTION級暫存資料表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,重新登入記錄也不存在

相關文章

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.