搜尋此網誌

2013年6月4日 星期二

[SQL] GLOBAL TEMPORARY TABLE

CREATE GLOBAL TEMPORARY TABLE tempname
(
  ..........
  ..........
)
ON COMMIT DELETE ROWS; --或者是 ON COMMIT PRESERVE ROWS;

兩個選項說明:
ON COMMIT DELETE ROWS:
   To specify that the lifetime of the inserted rows is for the duration of the transaction only
   通常會用commit語法來結束transaction,所以當transaction結束後,該資料即會消失。
ON COMMIT PRESERVE ROWS:
   To specify that the lifetime of the inserted rows is for the duration of the session

   即資料在session結束後才刪除。

沒有留言:

張貼留言