oracle儲存過程中使用臨時表
1、儲存過程中動態建立表失敗,提示許可權問題,execute immediate 'create global temporary t1 as select * from table1';
解決:
1-授權 create any table
2-儲存過程中加AUTHID CURRENT_USER
2、建立完全域性臨時表資料查詢為空,需要用到臨時表的型別知識,加關鍵字on commit preserve rows即可
3、刪除時候遇到問題
失敗:
14452, 00000, "attempt to create, alter or drop an index on temporary table already in use"
// *Cause: An attempt was made to create, alter or drop an index on temporary
// table which is already in use.
// *Action: All the sessions using the session-specific temporary table have
// to truncate table and all the transactions using transaction
// specific temporary table have to end their transactions.
解決:
truncate後drop