shrink收缩文件空间

对于本地管理的临时表空间,往往会遇到表空间文件扩展到很大,一般只是一个特别大的语句早这种局面,平常又不会使用这么大,这样就白白浪费文件系统的空间。这时可以使用shrink命令来实现收缩一下这个文件。执行此命令不影响系统继续分配临时段。
以下是执行命令前后temp文件所占空间对比:
-bash-3.2$ ll
total 50316748
-rw-r----- 1 oracle oinstall     7020544 Apr 15 14:07 control01.ctl
-rw-r----- 1 oracle oinstall     7020544 Apr 15 14:07 control02.ctl
-rw-r----- 1 oracle oinstall     7020544 Apr 15 14:07 control03.ctl
-rw-r--r-- 1 oracle oinstall    20979712 Apr 15 09:09 cwmlite01.dbf
-rw-r----- 1 oracle oinstall   629153792 Apr 15 09:09 u1
-rw-r--r-- 1 oracle oinstall    20979712 Apr 15 09:09 drsys01.dbf
-rw-r----- 1 oracle oinstall  1992302592 Apr 15 09:09 us_fee_idx
-rw-r----- 1 oracle oinstall  5976891392 Apr 15 09:09 us_fee_tab
-rw-r----- 1 oracle oinstall  5980037120 Apr 15 09:09 us_idx_l
-rw-r----- 1 oracle oinstall  1048584192 Apr 15 09:09 us_idx_s
-rw-r----- 1 oracle oinstall 15518932992 Apr 15 09:09 us_tab_l
-rw-r----- 1 oracle oinstall  1992302592 Apr 15 09:09 us_tab_s
-rw-r----- 1 oracle oinstall 13212065792 Apr 15 09:09 us_tab_xl
-rw-r--r-- 1 oracle oinstall   158605312 Apr 15 09:09 example01.dbf
-rw-r--r-- 1 oracle oinstall    26222592 Apr 15 09:09 indx01.dbf
-rw-r----- 1 oracle oinstall   734011392 Apr 15 09:09 jablog
-rw-r----- 1 oracle oinstall   734011392 Apr 15 09:09 jablog_blob
-rw-r--r-- 1 oracle oinstall    20979712 Apr 15 09:09 odm01.dbf
-rw-r----- 1 oracle oinstall   104858112 Apr 15 09:05 redo01.log
-rw-r----- 1 oracle oinstall   104858112 Apr 15 14:07 redo02.log
-rw-r----- 1 oracle oinstall   104858112 Apr 14 10:09 redo03.log
-rw-r----- 1 oracle oinstall   524296192 Apr 15 14:05 sysaux01.dbf
-rw-r--r-- 1 oracle oinstall   786440192 Apr 15 14:06 system01.dbf
-rw-r--r-- 1 oracle oinstall   688922624 Apr 14 22:09 temp01.dbf
SQL> alter tablespace temp shrink space keep 200m;
Tablespace altered.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
-bash-3.2$ pwd
/opt/oracle/oradata/db1
-bash-3.2$ ll
total 49850308
-rw-r----- 1 oracle oinstall     7020544 Apr 15 14:10 control01.ctl
-rw-r----- 1 oracle oinstall     7020544 Apr 15 14:10 control02.ctl
-rw-r----- 1 oracle oinstall     7020544 Apr 15 14:10 control03.ctl
-rw-r--r-- 1 oracle oinstall    20979712 Apr 15 09:09 cwmlite01.dbf
-rw-r----- 1 oracle oinstall   629153792 Apr 15 09:09 u1
-rw-r--r-- 1 oracle oinstall    20979712 Apr 15 09:09 drsys01.dbf
-rw-r----- 1 oracle oinstall  1992302592 Apr 15 09:09 us_fee_idx
-rw-r----- 1 oracle oinstall  5976891392 Apr 15 09:09 us_fee_tab
-rw-r----- 1 oracle oinstall  5980037120 Apr 15 09:09 us_idx_l
-rw-r----- 1 oracle oinstall  1048584192 Apr 15 09:09 us_idx_s
-rw-r----- 1 oracle oinstall 15518932992 Apr 15 09:09 us_tab_l
-rw-r----- 1 oracle oinstall  1992302592 Apr 15 09:09 us_tab_s
-rw-r----- 1 oracle oinstall 13212065792 Apr 15 09:09 us_tab_xl
-rw-r--r-- 1 oracle oinstall   158605312 Apr 15 09:09 example01.dbf
-rw-r--r-- 1 oracle oinstall    26222592 Apr 15 09:09 indx01.dbf
-rw-r----- 1 oracle oinstall   734011392 Apr 15 09:09 jablog
-rw-r----- 1 oracle oinstall   734011392 Apr 15 09:09 jablog_blob
-rw-r--r-- 1 oracle oinstall    20979712 Apr 15 09:09 odm01.dbf
-rw-r----- 1 oracle oinstall   104858112 Apr 15 09:05 redo01.log
-rw-r----- 1 oracle oinstall   104858112 Apr 15 14:10 redo02.log
-rw-r----- 1 oracle oinstall   104858112 Apr 14 10:09 redo03.log
-rw-r----- 1 oracle oinstall   524296192 Apr 15 14:05 sysaux01.dbf
-rw-r--r-- 1 oracle oinstall   786440192 Apr 15 14:06 system01.dbf
-rw-r--r-- 1 oracle oinstall   210771968 Apr 15 14:10 temp01.dbf
请使用浏览器的分享功能分享到微信等