Svenson's  Bulletin Board Forum Index Svenson's Bulletin Board
Bulletin Board for boat building and model airplane building enthusiasts.
 
AlbumAlbum   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Shell script to generate SQL to extend tablespaces to 20%

 
Post new topic   Reply to topic    Svenson's Bulletin Board Forum Index -> DB2
View previous topic :: View next topic  
Author Message
craig
Site Admin


Joined: 19 Feb 2006
Posts: 40

PostPosted: Tue Feb 28, 2006 6:38 am    Post subject: Shell script to generate SQL to extend tablespaces to 20% Reply with quote

#!/bin/ksh

Local()
{


echo "DBNAME1 DBNAME2"
}

Conts()
{
tsc=$1
noc=$2
need=$3

export Accessible=""
let cont=0

db2 list tablespace containers for $tsc show detail | egrep '=|^$' |
\
sed 's/[ ()]//g' | \
while read lineb
do
[ -z "$lineb" ] && continue
# echo export $lineb
eval export $lineb

[ ! -z "$Accessible" ] && {
let cont+=1

Pages=$(echo "" | awk '{ printf("%ld\n", TP *
(ND/100)) }' TP=$Totalpages ND=$need)
CM=","
[ $cont -eq $Numberofcontainers ] && CM=""

echo " $Type '$Name' $Pages$CM"
}
export Accessible=""
done
}

ShowInfo()
{
[ -z "$TablespaceID" ] && return

if [ "$Type" = "Systemmanagedspace" ] ; then

V="99"
typ="SMS"
else
V=$(echo "" | awk '{ printf("%d\n",(F/U)*100.0) }'
U=$Useablepages F=$Freepages)
typ="DMS"

fi

[ $V -le 20 ] && {
printf "-- %10.10s : %20.20s : %3d%% (%s) free\n" $db $Name
"$V" $typ
echo "alter tablespace $Name extend ("
Conts $TablespaceID $Numberofcontainers $(( 21 - $V ))
echo ");"
echo " "
}
}

for db in $(Local)
do
db2 -o- connect to $db

echo "connect to $db;"
echo " "

db2 list tablespaces show detail | egrep '=|^$' | \
sed 's/[ ()]//g' | \
while read line
do
[ -z "$line" ] && {
ShowInfo $db
continue
}

# echo export $line
eval export $line
done
done
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Svenson's Bulletin Board Forum Index -> DB2 All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group