监控表空间利用,数据文件
2009-12-13 23:10
211 查看
自己编写的监控表空间利用率的小脚本,这个脚本没有监控temp表空间
这个脚本按照表空间使用率降序排列
col tablespace_name format a15
col total_space format a10
col free_space format a10
col used_space format a10
col used_rate format 99.99
select a.tablespace_name,a.total_space_Mb||'m' total_space,b.free_space_Mb||'m' free_space,a.total_space_Mb-b.free_space_Mb||'m' used_space,
(1-(b.free_space_Mb/a.total_space_Mb))*100 used_rate,a.total_blocks,b.free_blocks from
(select tablespace_name,sum(bytes)/1024/1024 total_space_Mb,sum(blocks) total_blocks from dba_data_files group by tablespace_name) a,
(select tablespace_name, sum((bytes)/1024/1024) free_space_Mb,sum(blocks) free_blocks from dba_free_space group by tablespace_name) b
where a.tablespace_name=b.tablespace_name order by used_rate desc;
这个脚本格式化了百分比
col tablespace_name format a15
col total_space format a10
col free_space format a10
col used_space format a10
col used_rate format a10
select a.tablespace_name,a.total_space_Mb||'m' total_space,b.free_space_Mb||'m' free_space,a.total_space_Mb-b.free_space_Mb||'m' used_space,
round((1-(b.free_space_Mb/a.total_space_Mb)),4)*100||'%' used_rate,a.total_blocks,b.free_blocks from
(select tablespace_name,sum(bytes)/1024/1024 total_space_Mb,sum(blocks) total_blocks from dba_data_files group by tablespace_name) a,
(select tablespace_name, sum((bytes)/1024/1024) free_space_Mb,sum(blocks) free_blocks from dba_free_space group by tablespace_name) b
where a.tablespace_name=b.tablespace_name;
上面两个脚本没有考虑数据文件是否能自动增长,下面的脚本考虑数据文件能自动增长的情况
col tablespace_name heading Tablespace_Name
col allocated_space heading Allocated_Space
col free_space heading Free_Space(Mb)
col max_spacee heading Max_space(Mb)
select a.tablespace_name,a.total_space_mb allocated_space,round(b.free_space_mb,2) free_space,round(a.max_space,2) max_space,
round((a.total_space_mb-b.free_space_mb)/a.total_space_mb*100,2) pct_usage,round(a.total_space_mb/a.max_space*100,2) pct_allocated
from (select tablespace_name,sum(bytes)/1024/1024 total_space_Mb,decode(sum(maxbytes/1024/1024),0,
sum(bytes)/1024/1024,sum(maxbytes)/1024/1024) max_space
from dba_data_files group by tablespace_name)a,(select tablespace_name, sum((bytes)/1024/1024) free_space_Mb
from dba_free_space group by tablespace_name) b where a.tablespace_name=b.tablespace_name order by pct_allocated desc;
监控数据文件脚本
col max_size heading Max_Size(Gb)
col file_size heading File_Size(Mb)
col next heading Next(Bytes)
col autoextensible heading Auto
col file_name heading File_Name
col tablespace_name heading Tablespace_Name
col free_size heading Free_Size(Mb)
col used_rate heading Pct.used
select tablespace_name,file_name,bytes/1024/1024 file_size,round(a.free_size,2) free_size,autoextensible,increment_by next,round(maxbytes/1024/1024/1024)
max_size,round(((bytes/1024/1024)-a.free_size)/(bytes/1024/1024)*100,2) used_rate from dba_data_files b,(select file_id,sum(bytes)/1024/1024 free_size from dba_free_space group by file_id) a
where b.file_id=a.file_id order by used_rate desc;
这个脚本按照表空间使用率降序排列
col tablespace_name format a15
col total_space format a10
col free_space format a10
col used_space format a10
col used_rate format 99.99
select a.tablespace_name,a.total_space_Mb||'m' total_space,b.free_space_Mb||'m' free_space,a.total_space_Mb-b.free_space_Mb||'m' used_space,
(1-(b.free_space_Mb/a.total_space_Mb))*100 used_rate,a.total_blocks,b.free_blocks from
(select tablespace_name,sum(bytes)/1024/1024 total_space_Mb,sum(blocks) total_blocks from dba_data_files group by tablespace_name) a,
(select tablespace_name, sum((bytes)/1024/1024) free_space_Mb,sum(blocks) free_blocks from dba_free_space group by tablespace_name) b
where a.tablespace_name=b.tablespace_name order by used_rate desc;
这个脚本格式化了百分比
col tablespace_name format a15
col total_space format a10
col free_space format a10
col used_space format a10
col used_rate format a10
select a.tablespace_name,a.total_space_Mb||'m' total_space,b.free_space_Mb||'m' free_space,a.total_space_Mb-b.free_space_Mb||'m' used_space,
round((1-(b.free_space_Mb/a.total_space_Mb)),4)*100||'%' used_rate,a.total_blocks,b.free_blocks from
(select tablespace_name,sum(bytes)/1024/1024 total_space_Mb,sum(blocks) total_blocks from dba_data_files group by tablespace_name) a,
(select tablespace_name, sum((bytes)/1024/1024) free_space_Mb,sum(blocks) free_blocks from dba_free_space group by tablespace_name) b
where a.tablespace_name=b.tablespace_name;
上面两个脚本没有考虑数据文件是否能自动增长,下面的脚本考虑数据文件能自动增长的情况
col tablespace_name heading Tablespace_Name
col allocated_space heading Allocated_Space
col free_space heading Free_Space(Mb)
col max_spacee heading Max_space(Mb)
select a.tablespace_name,a.total_space_mb allocated_space,round(b.free_space_mb,2) free_space,round(a.max_space,2) max_space,
round((a.total_space_mb-b.free_space_mb)/a.total_space_mb*100,2) pct_usage,round(a.total_space_mb/a.max_space*100,2) pct_allocated
from (select tablespace_name,sum(bytes)/1024/1024 total_space_Mb,decode(sum(maxbytes/1024/1024),0,
sum(bytes)/1024/1024,sum(maxbytes)/1024/1024) max_space
from dba_data_files group by tablespace_name)a,(select tablespace_name, sum((bytes)/1024/1024) free_space_Mb
from dba_free_space group by tablespace_name) b where a.tablespace_name=b.tablespace_name order by pct_allocated desc;
监控数据文件脚本
col max_size heading Max_Size(Gb)
col file_size heading File_Size(Mb)
col next heading Next(Bytes)
col autoextensible heading Auto
col file_name heading File_Name
col tablespace_name heading Tablespace_Name
col free_size heading Free_Size(Mb)
col used_rate heading Pct.used
select tablespace_name,file_name,bytes/1024/1024 file_size,round(a.free_size,2) free_size,autoextensible,increment_by next,round(maxbytes/1024/1024/1024)
max_size,round(((bytes/1024/1024)-a.free_size)/(bytes/1024/1024)*100,2) used_rate from dba_data_files b,(select file_id,sum(bytes)/1024/1024 free_size from dba_free_space group by file_id) a
where b.file_id=a.file_id order by used_rate desc;
相关文章推荐
- 监控表空间利用,数据文件
- C# 利用FTP自动下载xml文件后利用 FileSystemWatcher 监控目录下文件变化并自动更新数据库
- 利用Oracle外部表监控文件系统的空间使用率
- ORA-01157: 无法标识/锁定数据文件(手动删除表空间的后果)
- 数据库、表空间、数据文件、表、数据之间关系
- Oracle10g数据文件的收缩与数据对象跨表空间的迁移
- AIX用裸设备给表空间添加数据文件
- Oracle移除表空间的数据文件 ora-00604 ora-01426
- Oracle误删表空间数据文件报错
- Oracle误删表空间数据文件报错
- 利用IStorage和IStream存储自定义数据到Inventor文件 (C++)
- Oracle 表空间与数据文件
- oracle数据库的实例、表空间、用户、数据文件等概念
- 利用内存映射文件在进程间共享数据
- oracle 显示表空间和数据文件信息
- 操作系统以外的硬盘空间-利用DOS/WINDOWS9X的隐含扇区保护数据 - 企鹅人生 - CSDNBlog
- 利用存储过程数据库中的数据生成txt文件
- 表空间收缩shrink数据文件
- 查看Oracle数据库表空间大小,是否需要增加表空间的数据文件
- oracle 回收表空间的数据文件大小