RE: Getting a table's dbspace
Posted in 1997
Try this script.
#!/bin/sh
if test $# -lt 1
then
echo "$0 dbname "
exit 1
fi
echo 'output to pipe "cat " without headings
select tabname,hex(partnum) from systables
where tabid > 99
order by tabname' | isql $1 2>/dev/null | grep -v "^$" |
nawk '
BEGIN {
while("onstat -D"| getline)
# The above line should be changed to the following if you are
working with 5.0
# while("tbstat -D"| getline)
{
if ( match($2,"active,"))
break
else
tbstatarr[$2]=$8
}
printf "Tablename Dbspace\\n"
printf "----------------- ------------\\n"
}
{
hexval=substr($2,3,3)
# The above line should be changed to the following if you are
working with 5.0
# hexval=substr($2,3,2)
retval=hextoint(hexval)
printf "%-18s %s\\n",$1,tbstatarr[retval]
}
function hextoint(a)
{
res=0
base=16
expn=0
for(i=length(a);i>0;i--)
{
val1=substr(a,i,1)
if(match(val1,"[Aa]"))
val1 = 10
if(match(val1,"[Bb]"))
val1 = 11
if(match(val1,"[Cc]"))
val1 = 12
if(match(val1,"[Dd]"))
val1 = 13
if(match(val1,"[Ee]"))
val1 = 14
if(match(val1,"[Ff]"))
val1 = 15
res=res + (val1 * (base^expn))
expn++
}
return res
}
'
Let me know whether it is helpful or not.
Thanks
Jay
> -----Original Message-----
> From: bweaver@fscorp.com [SMTP:bweaver@fscorp.com]
> Sent: Thursday, July 31, 1997 10:06 AM
> To: informix-list@rmy.emory.edu
> Subject: Getting a table's dbspace
>
> I'm trying to find out how to determine what tables are in a specific
> dbspace. I found
> what I thought was the answer on the IIUG web site, but it did not
> give the proper dbspace
> on my platform. The solution they gave was:
>
> SELECT TRUNC(partnum/16777216),tabname
> FROM systables
> WHERE tabtype = 'T'
>
> According to this method, all my tables fell into 2 dbspaces but I
> have 18 on my system
> currently! I took off the TRUNC to see what it was returning and it
> appeared that the
> decimal was off by one place so I multiplied the result by 10. This
> gave numbers that
> were in the right range (i.e. 1-18), but still did not match the
> dbspace as reported by
> dbschema.
>
> Is this method platform specific? If so, what is the method for my
> platform? I'm running
> 7.22 on a Sequent Symmetry 5000/SE40 which is running Dynix Ptx 4.2.1.
> -------------------------------------
> Name: Bill Weaver
> E-mail: bweaver@fscorp.com
> Date: 7/31/97
> Time: 9:06:25 AM
>
> This message was sent by Chameleon
> -------------------------------------