搜尋此網誌

2013年6月4日 星期二

[SQL] 誤DROP TABLE的救回法

不小心Drop Table的救回法,請執行以下SQL,

flashback table tablename to before drop;

不過,該語法只適用10g以後的版本,Drop Table前還是好好看清再做。

[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結束後才刪除。