Oracle 数据库表空间容量调整(表空间缩容脚本)脚本.pdf
文本预览下载声明
DDBBAA nneevveerr sslleeeepp--DDBBAA,,永永不不眠眠
FFooccuuss oonn OOrraaccllee DDaattaabbaassee,, GGooddeennGGaattee aanndd UUnniixx
[[ 顶顶]] OOrraaccllee 数数据据库库表表空空间间容容量量调调整整 ((表表空空间间缩缩容容脚脚本本))脚脚本本
分类: Automatic Storage Management Oracle DBA Tools Scripts 2013-05-31 19:18 308人阅读 评论 (0) 收
藏 举报
Oracle 数据库表空间表空间缩容表空间扩容表空间容量调整
--1、获取需要释放空间的表空间信息 (包含oracle database自有表空间)
--drop table system.tbs_detail;
create table system.tbs_detail as select
a.tablespace_name,
a.bytes/1024/1024 Sum_MB,
(a.bytes-b.bytes)/1024/1024 used_MB,
b.bytes/1024/1024 free_MB,
round(((a.bytes-b.bytes)/a.bytes)*100,2) percent_used
from
(select tablespace_name,sum (bytes) bytes from dba_data_files group by tablespace_name) a,
(select tablespace_name,sum (bytes) bytes,max (bytes) largest from dba_free_space group by
tablespace_name) b
where a.tablespace_name=b.tablespace_name
order by ((a.bytes-b.bytes)/a.bytes) desc;
--select * from system.tbs_detail order by Sum_MB desc,free_MB desc;
--2、获取需要释放空间的应用表空间数据文件使用情况
--drop table system.datafile_space;
create table system.datafile_space as
select a.TABLESPACE_NAME,
a.FILE_NAME,
a.BYTES / 1024 / 1024 total,
b.sum_free / 1024 / 1024 free
from dba_data_files a,
(select file_id, sum (bytes) sum_free
from dba_free_space
group by file_id) b
where a.FILE_ID = b.file_id
and a.TABLESPACE_NAME in (select tablespace_name
from system.tbs_detail
where (tablespace_name like %CQLT% or
tablespace_name like %CQST%
or tablespace_name like TS% or
tablespace_name like IDX%
or tablespace_name like %HX%)
and Sum_MB 100);
--select * from system.datafile_space;
--3、生成数据文件大小重 脚本,在每个数据文件当前实际使用空间大小基础上增加 100m 空间
select alte
显示全部