- 最后登录
- 2023-8-16
- 在线时间
- 1686 小时
- 威望
- 2135
- 金钱
- 50532
- 注册时间
- 2011-10-12
- 阅读权限
- 200
- 帖子
- 5207
- 精华
- 39
- 积分
- 2135
- UID
- 2
|
5#
发表于 2011-12-8 19:52:19
你好,
就输出结果来看system表空间确实有大量空闲空间
SYSTEM 7500 7161 340 95 5 7500
一般这些空闲空间是可以回收的 但是请注意 resize的大小 过小可能导致 ORA-03297: file contains used data beyond requested RESIZE value 错误
如:- SQL> alter database datafile '/s01/oradata/G10R21/datafile/o1_mf_system_7ch8004t_.dbf' autoextend on next 200M maxsize unlimited;
- Database altered.
- SQL> create table tl(t1 int) tablespace system;
- Table created.
- SQL> alter table tl allocate extent ( size 2000M);
- Table altered.
- SQL> REM tablespace report
- SQL>
- SQL> set linesize 200
- SQL>
- SQL> select a.tablespace_name,
- 2 round(a.bytes_alloc / 1024 / 1024) megs_alloc,
- 3 round(nvl(b.bytes_free, 0) / 1024 / 1024) megs_free,
- 4 round((a.bytes_alloc - nvl(b.bytes_free, 0)) / 1024 / 1024) megs_used,
- 5 round((nvl(b.bytes_free, 0) / a.bytes_alloc) * 100) Pct_Free,
- 6 100 - round((nvl(b.bytes_free, 0) / a.bytes_alloc) * 100) Pct_used,
- 7 round(maxbytes / 1048576) Max
- 8 from (select f.tablespace_name,
- 9 sum(f.bytes) bytes_alloc,
- 10 sum(decode(f.autoextensible, 'YES', f.maxbytes, 'NO', f.bytes)) maxbytes
- 11 from dba_data_files f
- 12 group by tablespace_name) a,
- 13 (select f.tablespace_name, sum(f.bytes) bytes_free
- 14 from dba_free_space f
- 15 group by tablespace_name) b
- 16 where a.tablespace_name = b.tablespace_name(+)
- 17 union all
- 18 select h.tablespace_name,
- 19 round(sum(h.bytes_free + h.bytes_used) / 1048576) megs_alloc,
- 20 round(sum((h.bytes_free + h.bytes_used) - nvl(p.bytes_used, 0)) /
- 21 1048576) megs_free,
- 22 round(sum(nvl(p.bytes_used, 0)) / 1048576) megs_used,
- 23 round((sum((h.bytes_free + h.bytes_used) - nvl(p.bytes_used, 0)) /
- 24 sum(h.bytes_used + h.bytes_free)) * 100) Pct_Free,
- 25 100 -
- 26 round((sum((h.bytes_free + h.bytes_used) - nvl(p.bytes_used, 0)) /
- 27 sum(h.bytes_used + h.bytes_free)) * 100) pct_used,
- 28 round(sum(f.maxbytes) / 1048576) max
- 29 from sys.v_$TEMP_SPACE_HEADER h,
- 30 sys.v_$Temp_extent_pool p,
- 31 dba_temp_files f
- 32 where p.file_id(+) = h.file_id
- 33 and p.tablespace_name(+) = h.tablespace_name
- 34 and f.file_id = h.file_id
- 35 and f.tablespace_name = h.tablespace_name
- 36 group by h.tablespace_name
- 37 ORDER BY 1
- 38 /
- TABLESPACE_NAME MEGS_ALLOC MEGS_FREE MEGS_USED PCT_FREE PCT_USED MAX
- ------------------------------ ---------- ---------- ---------- ---------- ---------- ----------
- EXAMPLE 171 3 168 2 98 32768
- SYSAUX 310 44 266 14 86 32768
- SYSTEM 5700 190 5510 3 97 32768
- TEMP 2968 2968 0 100 0 32768
- UNDOTBS1 1165 825 340 71 29 32768
- USERS 8985 36 8950 0 100 32768
- 6 rows selected.
- SQL> drop table tl;
- Table dropped.
- SQL> REM tablespace report
- SQL>
- SQL> set linesize 200
- SQL>
- SQL> select a.tablespace_name,
- 2 round(a.bytes_alloc / 1024 / 1024) megs_alloc,
- 3 round(nvl(b.bytes_free, 0) / 1024 / 1024) megs_free,
- 4 round((a.bytes_alloc - nvl(b.bytes_free, 0)) / 1024 / 1024) megs_used,
- 5 round((nvl(b.bytes_free, 0) / a.bytes_alloc) * 100) Pct_Free,
- 6 100 - round((nvl(b.bytes_free, 0) / a.bytes_alloc) * 100) Pct_used,
- 7 round(maxbytes / 1048576) Max
- 8 from (select f.tablespace_name,
- 9 sum(f.bytes) bytes_alloc,
- 10 sum(decode(f.autoextensible, 'YES', f.maxbytes, 'NO', f.bytes)) maxbytes
- 11 from dba_data_files f
- 12 group by tablespace_name) a,
- 13 (select f.tablespace_name, sum(f.bytes) bytes_free
- 14 from dba_free_space f
- 15 group by tablespace_name) b
- 16 where a.tablespace_name = b.tablespace_name(+)
- 17 union all
- 18 select h.tablespace_name,
- 19 round(sum(h.bytes_free + h.bytes_used) / 1048576) megs_alloc,
- 20 round(sum((h.bytes_free + h.bytes_used) - nvl(p.bytes_used, 0)) /
- 21 1048576) megs_free,
- 22 round(sum(nvl(p.bytes_used, 0)) / 1048576) megs_used,
- 23 round((sum((h.bytes_free + h.bytes_used) - nvl(p.bytes_used, 0)) /
- 24 sum(h.bytes_used + h.bytes_free)) * 100) Pct_Free,
- 25 100 -
- 26 round((sum((h.bytes_free + h.bytes_used) - nvl(p.bytes_used, 0)) /
- 27 sum(h.bytes_used + h.bytes_free)) * 100) pct_used,
- 28 round(sum(f.maxbytes) / 1048576) max
- 29 from sys.v_$TEMP_SPACE_HEADER h,
- 30 sys.v_$Temp_extent_pool p,
- 31 dba_temp_files f
- 32 where p.file_id(+) = h.file_id
- 33 and p.tablespace_name(+) = h.tablespace_name
- 34 and f.file_id = h.file_id
- 35 and f.tablespace_name = h.tablespace_name
- 36 group by h.tablespace_name
- 37 ORDER BY 1
- 38 /
- TABLESPACE_NAME MEGS_ALLOC MEGS_FREE MEGS_USED PCT_FREE PCT_USED MAX
- ------------------------------ ---------- ---------- ---------- ---------- ---------- ----------
- EXAMPLE 171 3 168 2 98 32768
- SYSAUX 310 44 266 14 86 32768
- SYSTEM 5700 2242 3458 39 61 32768
- TEMP 2968 2968 0 100 0 32768
- UNDOTBS1 1165 825 340 71 29 32768
- USERS 8985 36 8950 0 100 32768
- 6 rows selected.
- SQL> alter database datafile '/s01/oradata/G10R21/datafile/o1_mf_system_7ch8004t_.dbf' resize 5000M;
- Database altered.
- SQL> REM tablespace report
- SQL>
- SQL> set linesize 200
- SQL>
- SQL> select a.tablespace_name,
- 2 round(a.bytes_alloc / 1024 / 1024) megs_alloc,
- 3 round(nvl(b.bytes_free, 0) / 1024 / 1024) megs_free,
- 4 round((a.bytes_alloc - nvl(b.bytes_free, 0)) / 1024 / 1024) megs_used,
- 5 round((nvl(b.bytes_free, 0) / a.bytes_alloc) * 100) Pct_Free,
- 6 100 - round((nvl(b.bytes_free, 0) / a.bytes_alloc) * 100) Pct_used,
- 7 round(maxbytes / 1048576) Max
- 8 from (select f.tablespace_name,
- 9 sum(f.bytes) bytes_alloc,
- 10 sum(decode(f.autoextensible, 'YES', f.maxbytes, 'NO', f.bytes)) maxbytes
- 11 from dba_data_files f
- 12 group by tablespace_name) a,
- 13 (select f.tablespace_name, sum(f.bytes) bytes_free
- 14 from dba_free_space f
- 15 group by tablespace_name) b
- 16 where a.tablespace_name = b.tablespace_name(+)
- 17 union all
- 18 select h.tablespace_name,
- 19 round(sum(h.bytes_free + h.bytes_used) / 1048576) megs_alloc,
- 20 round(sum((h.bytes_free + h.bytes_used) - nvl(p.bytes_used, 0)) /
- 21 1048576) megs_free,
- 22 round(sum(nvl(p.bytes_used, 0)) / 1048576) megs_used,
- 23 round((sum((h.bytes_free + h.bytes_used) - nvl(p.bytes_used, 0)) /
- 24 sum(h.bytes_used + h.bytes_free)) * 100) Pct_Free,
- 25 100 -
- 26 round((sum((h.bytes_free + h.bytes_used) - nvl(p.bytes_used, 0)) /
- 27 sum(h.bytes_used + h.bytes_free)) * 100) pct_used,
- 28 round(sum(f.maxbytes) / 1048576) max
- 29 from sys.v_$TEMP_SPACE_HEADER h,
- 30 sys.v_$Temp_extent_pool p,
- 31 dba_temp_files f
- 32 where p.file_id(+) = h.file_id
- 33 and p.tablespace_name(+) = h.tablespace_name
- 34 and f.file_id = h.file_id
- 35 and f.tablespace_name = h.tablespace_name
- 36 group by h.tablespace_name
- 37 ORDER BY 1
- 38 /
- TABLESPACE_NAME MEGS_ALLOC MEGS_FREE MEGS_USED PCT_FREE PCT_USED MAX
- ------------------------------ ---------- ---------- ---------- ---------- ---------- ----------
- EXAMPLE 171 3 168 2 98 32768
- SYSAUX 310 44 266 14 86 32768
- SYSTEM 5000 1542 3458 31 69 32768
- TEMP 2968 2968 0 100 0 32768
- UNDOTBS1 1165 825 340 71 29 32768
- USERS 8985 36 8950 0 100 32768
- 6 rows selected.
- SQL> alter database datafile '/s01/oradata/G10R21/datafile/o1_mf_system_7ch8004t_.dbf' resize 3460;
- alter database datafile '/s01/oradata/G10R21/datafile/o1_mf_system_7ch8004t_.dbf' resize 3460
- *
- ERROR at line 1:
- ORA-03214: File Size specified is smaller than minimum required
- SQL> alter database datafile '/s01/oradata/G10R21/datafile/o1_mf_system_7ch8004t_.dbf' resize 3460M;
- alter database datafile '/s01/oradata/G10R21/datafile/o1_mf_system_7ch8004t_.dbf' resize 3460M
- *
- ERROR at line 1:
- ORA-03297: file contains used data beyond requested RESIZE value
- SQL> alter database datafile '/s01/oradata/G10R21/datafile/o1_mf_system_7ch8004t_.dbf' resize 3470M;
- Database altered.
- SQL> REM tablespace report
- SQL>
- SQL> set linesize 200
- SQL>
- SQL> select a.tablespace_name,
- 2 round(a.bytes_alloc / 1024 / 1024) megs_alloc,
- 3 round(nvl(b.bytes_free, 0) / 1024 / 1024) megs_free,
- 4 round((a.bytes_alloc - nvl(b.bytes_free, 0)) / 1024 / 1024) megs_used,
- 5 round((nvl(b.bytes_free, 0) / a.bytes_alloc) * 100) Pct_Free,
- 6 100 - round((nvl(b.bytes_free, 0) / a.bytes_alloc) * 100) Pct_used,
- 7 round(maxbytes / 1048576) Max
- 8 from (select f.tablespace_name,
- 9 sum(f.bytes) bytes_alloc,
- 10 sum(decode(f.autoextensible, 'YES', f.maxbytes, 'NO', f.bytes)) maxbytes
- 11 from dba_data_files f
- 12 group by tablespace_name) a,
- 13 (select f.tablespace_name, sum(f.bytes) bytes_free
- 14 from dba_free_space f
- 15 group by tablespace_name) b
- 16 where a.tablespace_name = b.tablespace_name(+)
- 17 union all
- 18 select h.tablespace_name,
- 19 round(sum(h.bytes_free + h.bytes_used) / 1048576) megs_alloc,
- 20 round(sum((h.bytes_free + h.bytes_used) - nvl(p.bytes_used, 0)) /
- 21 1048576) megs_free,
- 22 round(sum(nvl(p.bytes_used, 0)) / 1048576) megs_used,
- 23 round((sum((h.bytes_free + h.bytes_used) - nvl(p.bytes_used, 0)) /
- 24 sum(h.bytes_used + h.bytes_free)) * 100) Pct_Free,
- 25 100 -
- 26 round((sum((h.bytes_free + h.bytes_used) - nvl(p.bytes_used, 0)) /
- 27 sum(h.bytes_used + h.bytes_free)) * 100) pct_used,
- 28 round(sum(f.maxbytes) / 1048576) max
- 29 from sys.v_$TEMP_SPACE_HEADER h,
- 30 sys.v_$Temp_extent_pool p,
- 31 dba_temp_files f
- 32 where p.file_id(+) = h.file_id
- 33 and p.tablespace_name(+) = h.tablespace_name
- 34 and f.file_id = h.file_id
- 35 and f.tablespace_name = h.tablespace_name
- 36 group by h.tablespace_name
- 37 ORDER BY 1
- 38 /
- TABLESPACE_NAME MEGS_ALLOC MEGS_FREE MEGS_USED PCT_FREE PCT_USED MAX
- ------------------------------ ---------- ---------- ---------- ---------- ---------- ----------
- EXAMPLE 171 3 168 2 98 32768
- SYSAUX 310 44 266 14 86 32768
- SYSTEM 3470 12 3458 0 100 32768
- TEMP 2968 2968 0 100 0 32768
- UNDOTBS1 1165 825 340 71 29 32768
- USERS 8985 36 8950 0 100 32768
- 6 rows selected.
复制代码 |
|