温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

oracle 表空间查看脚本

发布时间:2020-06-05 04:39:53 来源:网络 阅读:473 作者:shangshanyang 栏目:关系型数据库

#!/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中验证


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI