#!/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 frg -cr [] [-q] # Generate statement to create tablespace, if no tbs name, # then create statement for all. -b : figures in bytes -dus : Disk usage per user per tablespace -g : figures in Giga bytes -i : List metadata info on tablespaces -rn : Limite selection to rows -q : add user quota on tbs -os : List Object size -t : limit to this tablespace, it accpet partial name -h : this help EOF exit } typeset -u PAR2 typeset -u fnew typeset -u ftbs ROWNUM=30 while [ -n "$1" ] do case "$1" in -b | b ) UNIT=B;; -g | g ) UNIT=G ; VAR=Gigs;; -cr ) CHOICE=CREATE if [ -n "$2" -a ! "$2" = '-q' ] ;then ftbs=$2; shift fi ;; -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 ;; -new ) fnew=$2 ; shift ;; -os ) CHOICE=LIST_OBJECT_SIZE;; -q ) QUOTA=TRUE ;; -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" = "CREATE" ];then if [ -n "$ftbs" ];then WHERE=" where tablespace_name = '$ftbs' " fi if [ "$QUOTA" = "TRUE" ];then SQL_QUOTA="select 'alter user ' || USERNAME || ' quota ' || decode (MAX_BYTES,-1,' unlimited' , MAX_BYTES ) || ' on ' || TABLESPACE_NAME || ';' from dba_ts_quotas $WHERE order by username ;" fi 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 sqlplus -s "$CONNECT_STRING" <