>/home/oracl..."/>
溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

oracle 表空間查看腳本

發(fā)布時間:2020-06-05 04:39:53 來源:網(wǎng)絡(luò) 閱讀:486 作者:shangshanyang 欄目:關(guān)系型數(shù)據(jù)庫

#!/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;

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

將上述內(nèi)容保存到/tmp/tablespace.sh中

然后通過crontab  -l -u oracle命令新建計(jì)劃任務(wù)如下:

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

則每小時將會執(zhí)行一次腳本,結(jié)果將會保存到home/oracle/tablespace.log中

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

以上為在redhat6.4中驗(yàn)證


向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI