码迷,mamicode.com
首页 > 数据库 > 详细

oracle 表空间查看脚本

时间:2016-11-28 01:33:59      阅读:203      评论:0      收藏:0      [点我收藏+]

标签:oracle   表空间   


#!/bin/bash
echo -e "\n\n*********~~~~~~~~~~~~~~~~~~~~~~~~~~~~DATE:" `date ‘+%Y/%m/%d   %T‘` "~~~~~~~~~~~~~~~~~~~~~~~*********" >>/home/oracle/tablespace.log
export PATH=/opt/oracle/1102/db01/bin:$PATH
export ORACLE_HOME=/opt/oracle/1102/db01/
sqlplus -S /nolog <<eof
conn xx/xx@orcl
spool /home/oracle/tablespace.log append

set line 200;
set feedback off;
set pagesize 50000;
col member for a45;

select a.tablespace_name,a.summary,b.free,b.maxf "MAX_FREE_EXTENT",b.free_exts "FREE_EXTENTS",
    100-b.free/a.summary*100 "USED%"
        from
           (select tablespace_name,sum(bytes/1024/1024) "SUMMARY" from dba_data_files
               group by tablespace_name) a,
                   (select tablespace_name,sum(bytes/1024/1024) "FREE",max(bytes/1024/1024)
                      "MAXF" ,count(*) free_exts
                          from dba_free_space group by tablespace_name) b
                              where a.tablespace_name=b.tablespace_name
                                 order by 6 desc;
--col SQL_TEXT for a50
--select t.SQL_TEXT,t.VERSION_COUNT,t.SHARABLE_MEM from v\$sqlarea t where t.VERSION_COUNT>6;
                                 spool off;

eof
df -m >>/home/oracle/tablespace.log

                                 exit;

######################################################

将上述内容保存到/tmp/tablespace.sh中

然后通过crontab  -l -u oracle命令新建计划任务如下:

1 * * * * /bin/bash  tmp/tablespace.sh

则每小时将会执行一次脚本,结果将会保存到home/oracle/tablespace.log中

######################################################

以上为在redhat6.4中验证


本文出自 “银河系|计算机网络” 博客,请务必保留此出处http://qqran.blog.51cto.com/10014850/1877099

oracle 表空间查看脚本

标签:oracle   表空间   

原文地址:http://qqran.blog.51cto.com/10014850/1877099

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!