Oracle 数据库表空间容量调整(表空间缩容脚本)脚本
2013-05-31 19:18
495 查看
--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 'alter database datafile ''' || file_name || ''' resize ' ||
round(to_number(total - free + 100),0) || ' M;'
from system.datafile_space;
--查看 ASM 磁盘组使用情况
sqlplus / as sysdba <<EOF
set feed off
set linesize 200
set pagesize 200
set echo off
spool /home/oracle/check_log/chktbs.log append
select name,state,type,total_mb,free_mb from v\$asm_diskgroup;
spool off
quit
EOF
转载请注明作者出处及原文链接,否则将追究法律责任:
作者:xiangsir
原文链接:http://blog.csdn.net/xiangsir/article/details/9002201
QQ:444367417
MSN:xiangsir@hotmail.com
--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 'alter database datafile ''' || file_name || ''' resize ' ||
round(to_number(total - free + 100),0) || ' M;'
from system.datafile_space;
--查看 ASM 磁盘组使用情况
sqlplus / as sysdba <<EOF
set feed off
set linesize 200
set pagesize 200
set echo off
spool /home/oracle/check_log/chktbs.log append
select name,state,type,total_mb,free_mb from v\$asm_diskgroup;
spool off
quit
EOF
转载请注明作者出处及原文链接,否则将追究法律责任:
作者:xiangsir
原文链接:http://blog.csdn.net/xiangsir/article/details/9002201
QQ:444367417
MSN:xiangsir@hotmail.com
相关文章推荐
- [置顶] Oracle 数据库表空间容量调整(表空间缩容脚本)脚本
- 表空间脚本[置顶] Oracle 数据库表空间容量调整(表空间缩容脚本)脚本
- Oracle提取现有数据库表空间、角色、用户信息,并生成脚本
- Oracle 数据库 增加表空间容量
- Oracle 表空间调整脚本
- Oracle 数据库 用脚本建表空间
- Oracle - 数据库的实例、表空间、用户、表之间关系
- Oracle 创建定时计划备份数据库脚本。
- oracle导入导出命令详解(附数据库每天定时备份脚本)
- ORACLE 中SCHEMA的概念以及数据库,表空间,数据文件等的区别(转)
- Oracle 查看表空间使用率 SQL 脚本
- Oracle 数据库中查看表空间的2种方法
- Oracle的几个概念:数据库名,全局数据库名,SID,实例,命名空间,schema
- 数据库(Oracle)运维工作内容及常用脚本命令
- oracle 9i 数据库UNDO表空间释放
- 验证:oracle delete 数据库空间是可以重新被使用的
- oracle 11g linux 建立表空间 用户 授权 数据库导入导出
- oracle linux 5 中随系统自动启动停止数据库oracle 11g R2的脚本
- Oracle 数据库、实例、用户、表空间、表之间的关系
- 设备脚本Oracle 11.2 在裸设备上创建数据库