#!/usr/bin/ksh # HOST=`hostname` HOST=`echo $HOST | awk '{ printf ("%-+15.15s",$1) }'` SBIN2=${SBIN}/module2 WK_SBIN=${SBIN}/module2/s5 TMP=$SBIN/tmp FOUT=$TMP/free_space_summary_$ORACLE_SID.txt function help { cat < ] frg -os -t -rn -u frg -i frg -dus # If is not given then all schema are processed -b : figures in bytes -dus: Disk usage per user per tablespace -g : figures in Giga bytes -i : List metadata info on tablespaces -t : limit to this tablespace, it accpet partial name -os : List Object size -rn : Limite selection to rows -h : this help EOF exit } typeset -u PAR2 ROWNUM=30 while [ -n "$1" ] do case "$1" in -b | b ) UNIT=B;; -g | g ) UNIT=G ; VAR=Gigs;; -i ) CHOICE=INFO ;; -dus ) CHOICE=DUS if [ -n "$2" ];then TARGET_OWNER=$2 ; shift WHERE=where unset OWN_SYS AND_OWNER=" OWNER=upper('$TARGET_OWNER')" fi ;; -os ) CHOICE=LIST_OBJECT_SIZE;; -u ) AND_OWNER=" and owner = upper('$2')"; shift ;; -t ) PAR2=$2 ; AND_TBS=" and b.tablespace_name like '%$PAR2%'"; shift ;; -rn ) ROWNUM=$2; shift ;; -h ) help ;; * ) echo "Unknonw parameters $1";; esac shift done UNIT=${UNIT:-M} VAR=${VAR:-Megs} . $SBIN/scripts/passwd.env . ${GET_PASSWD} $S_USER $ORACLE_SID if [ "x-$CONNECT_STRING" = "x-" ];then echo "could no get the password of $S_USER" exit 0 fi echo if [ $UNIT = 'B' ];then sqlplus -s "$CONNECT_STRING" @$WK_SBIN/smenu_free_space_summary $HOST $ORACLE_SID $FOUT exit fi if [ "$UNIT" = "M" ];then DIV=1048576 SIZE_MB="Size(mb)" else DIV=1073741824 SIZE_MB="Size(G)" fi if [ "$CHOICE" = "DUS" ];then set -x sqlplus -s "$CONNECT_STRING" < (Select Max(bytes) From dba_free_space Where Tablespace_name = x.Tablespace_name) and next_extent > (Select Max(Maxbytes - Bytes) From dba_data_files Where Tablespace_name = x.Tablespace_name) Group by tablespace_name ) s where a.tablespace_name = b.tablespace_name (+) and a.Tablespace_name = S.Tablespace_name(+) / prompt exit !EOF elif [ "$CHOICE" = "LIST_OBJECT_SIZE" ];then if [ -n "$PAR2" ];then WHERE_TABLESPACE_NAME="where tablespace_name = upper('$PAR2')" else TBS=" , tablespace_name " fi #cat < return tablespace list a=2 sqlplus -s "$CONNECT_STRING" <