Oracle临时文件

临时数据文件时一种特殊的文件,当内存不足时,Oracle用他来存储一些临时数据,如排序或散列操作。

自12c起,对临时表的操作所产生的undo也会放到临时表空间中,而在12c之前,这部分undo放在undo表空间,联动产生redo。

临时表空间以稀疏(sparse)的方式创建

SQL> !df -h /DATA
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_test1-LogVol06
                       20G  1.9G   17G  11% /DATA

SQL> create temporary tablespace temp_huge
  2  tempfile '/DATA/temp_huge.dbf' size 2g;

Tablespace created.

SQL> !df -h /DATA
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_test1-LogVol06
                       20G  1.9G   17G  11% /DATA

SQL> !ls -l /DATA/temp_huge.dbf
-rw-r-----. 1 oracle dba 2147491840 Dec 14 17:00 /DATA/temp_huge.dbf

df命令查看,这个文件并没有占多少存储空间,但是用ls命令列出这个文件时,又显示为正常的2GB。

使用cp命令创建一个非稀疏文件

SQL> !cp --sparse=never /DATA/temp_huge.dbf /DATA/temp_huge_not_sparse.dbf

SQL> !df -h /DATA
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_test1-LogVol06
                       20G  3.9G   15G  21% /DATA

SQL> drop tablespace temp_huge including contents and datafiles;

Tablespace dropped.

SQL> create temporary tablespace temp_huge
  2  tempfile '/DATA/temp_huge_not_sparse.dbf' reuse;

Tablespace created.

原文地址:https://www.cnblogs.com/guilingyang/p/6180092.html