sheel script - automatic tablespace addition in oracle 11g

     sheel script - automatic tablespace addition in oracle 11g



#!/bin/bash
a=`sqlplus -s / as sysdba <<END
set pagesize 0 feedback off verify off heading off echo off;
select tablespace_name from dba_segments group by tablespace_name having SUM(BYTES)/1024/1024>700;
END`
f=${#a}
c=0
for file in $a ; do
eval "var$c=$file";
c=$((c+1));
done
echo $var0
array1=$(df -kh | grep '/u0*'|awk '{ print $6}')
array2=$(df -kh | grep '/u0*'|awk '{ print $5}')
size=${#array1}
size1=${#array2}
if ["$size" -eq 4] && ["$size1" -eq 3] && ["$array2" -gt 85%] && ["$f" -eq 1]
then
d=${array1[0]:0:4}
sqlplus /nolog <<END
connect /as sysdba
alter tablespace $a add datafile '$d/$a01.dbf' size 10m autoextend on maxsize 28G;
END`
fi
if ["$size" -eq 9] && ["$size1" -eq 3] && ["$array2 -gt 85%"] && ["$f" -eq 2]
then
d=${array1[0]:0:4}
sqlplus /nolog <<END
connect /as sysdba
alter tablespace $a add datafile '$d/$a01.dbf' size 10m autoextend on maxsize 28G;
END`
fi



check this out !!

dont forget to comment cheers !


Comments

Popular posts from this blog

Query for Tablespace usage with Autoextend

How to configure multiple Oracle listeners