2017-07-20 64 views

回答

-1
Create temporary table using the following statement 

CREATE GLOBAL TEMPORARY TABLE my_temp_table (
     id   NUMBER, 
     description VARCHAR2(20) 
    ) 
    ON COMMIT PRESERVE ROWS; 


    ON COMMIT PRESERVE ROWS clause indicates that rows should persist beyond the end of the transaction. They will only be removed at the end of the session. 
+0

這隻適用於Oracle,不適用於MSSQL。我想在ANSI SQL中執行此操作,以便它不依賴於數據庫。 – Ashutosh

+0

@Ashutosh總是不可能的,每個數據庫都有自己的一組關鍵字和數據類型。所有數據庫都沒有單一語法。 –

+0

@Sudipta我明白這一點。我正在努力改變實現,以便根據使用的數據庫選擇查詢。我現在面臨的問題是我需要在DB2,MSSQL和Oracle的單個查詢中實現「僅在存在Else Truncate時創建表」。你有什麼建議嗎? – Ashutosh