script to calculate the size of table
427256Feb 5 2008 — edited Feb 5 2008I am very new to scripting. My first script i need to make is for finding the total size of my oracle tables.
I have to provide two inputs that is the database name and tabale name
and the script should give me the size. This script will also be incorporated in crontab for checking the size of a particular table which is for txn logging and will be mailing us when the size of the table reaches 1gigs.
what i have in mind till yet is
#!/usr/bin/ksh
# Script to find sze of the table
# usage ./truncate_table.ksh ORACLE_SID TABLE_NAME
#
set -x
export ORACLE_HOME=/opt/oracle/product/9.2.0.4
SUMMARY=/tmp/truncate_table.log
date > $SUMMARY
export ORACLE_SID=$1
echo $ORACLE_SID
export TABLE_NAME=$2
if [ -z $ORACLE_SID ]
then
echo "Oracle SID not set"
exit
fi
export PATH=$ORACLE_HOME/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/openwin/bin:/usr/dt/bin:/opt/rational/clearcase/bin:/usr/local/samba/bin:/
export/home/oracle/bin:/u01/oracle/admin/adhoc:/opt/oracle/OPatch:/usr/ccs/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
${ORACLE_HOME}/bin/sqlplus -s '/ as sysdba'<<EOF>>$SUMMARY
set pagesize 0 feedback on verify on heading off echo on
select (bytes/1024/1024) as total_gigs from dba_segments where owner='SIEBEL' and segment_name='$TABLE_NAME'
exit;
EOF
But this is not working...
CAn someone help