天天看點

Shrinking a Locally Managed Temporary Tablespace

Shrinking a Locally Managed Temporary Tablespace

      Large sortoperations performed by the database may result in a temporarytablespace growing and occupying a considerable amount of diskspace. After the sort operation completes, the extra space is notreleased; it is just marked as free and available for reuse.Therefore, a single large sort operation might result in a largeamount of allocated temporary space that remains unused after thesort operation is complete. For this reason, the database enablesyou to shrink locally managed temporary tablespaces and releaseunused space.

      執行大的排序操作可能導緻臨時表空間占用比較大的磁盤空間。排序操作完成後,臨時表空間額外的空間的并不跟着回收。僅僅标記為空閑和可以被重新使用。是以,一個大的排序操作完成導緻大量的臨時表空間保持unused。基于這個原因,shrink本地管理的臨時表空間,釋放unused的空間。

      You use theSHRINK SPACE clause of the ALTER TABLESPACE statement to shrink atemporary tablespace, or the SHRINK TEMPFILE clause of the ALTERTABLESPACE statement to shrink a specific temp file of a temporarytablespace. Shrinking frees as much space as possible whilemaintaining the other attributes of the tablespace or temp file.The optional KEEP clause defines a minimum size for the tablespaceor temp file.

      使用帶有子句SHRINKSPACE的ALTER TABLESPACE語句shrink一個臨時表空間,或者帶有子句SHRINK TEMPFILE的ALTERTABLESPACE語句shrink指定的臨時表空間的臨時檔案。當維護其他屬性的表空間和臨時檔案,Shrinking釋放盡可能多的空間。KEEP子句定義了表空間或者臨時檔案的最小的尺寸。

      Shrinking isan online operation, which means that user sessions can continue toallocate sort extents if needed, and already-running queries arenot affected.

      Shrinking是一個online操作,意味着不會影響使用者可以配置設定排序區和已經運作的查詢。

      Thefollowing example shrinks the locally managed temporary tablespacelmtmp1 to a size of 20M.

    下面是一個Shrinks本地管理臨時表空間lmtmp1到20M的例子:

      ALTERTABLESPACE lmtemp1 SHRINK SPACE KEEP 20M;

      Thefollowing example shrinks the temp file lmtemp02.dbf of the locallymanaged temporary tablespace lmtmp2. Because the KEEP clause isomitted, the database attempts to shrink the temp file to theminimum possible size.

      下面的例子是shrinks本地管理的臨時表空間lmtmp2的臨時檔案lmtemp02.dbf。因為忽略KEEP子句,資料庫嘗試shrink臨時檔案可能最小的尺寸。

      ALTERTABLESPACE lmtemp2 SHRINK TEMPFILE'/u02/oracle/data/lmtemp02.dbf';