Re: Another how to question
Posted in 1998
Here are a couple of scripts which will do the trick for both V5 and V7.
Works on Solaris, HP/UX and DG/UX. Just cut and paste directy into scripts.
(dont forget to chmod +x). then run
showtab <tablename>
== showtab script ==
TABLE=$1
INFREL=`dbaccess -V | head -1 | awk '{print substr($3,1,1)}'`
echo "Determining Existing DBSpaces/Extents for $TABLE `date`"
if [ "$INFREL" = "7" ]; then
echo "select tabname, hex(partnum) hexpn, fextsize, nextsize from
systables where tabname = \\"$TABLE\\"" | dbaccess $DBASE 2> /dev/null | awk
'/0x/ {print $1, substr($2,1,5), $3, $4}' | read TABTEST HEXPN FEXTSIZE
NEXTSIZE > /dev/null
else
echo "select tabname, hex(partnum) hexpn, fextsize, nextsize from
systables where tabname = \\"$TABLE\\"" | dbaccess $DBASE 2> /dev/null | awk
'/0x/ {print $1, substr($2,1,4), $3, $4}' | read TABTEST HEXPN FEXTSIZE
NEXTSIZE > /dev/null
fi
DBSPACE=`get_dbspaces $HEXPN`
echo "$TABTEST $HEXPN=$DBSPACE $FEXTSIZE $NEXTSIZE"
== get_dbspaces script ==
INFREL=`dbaccess -V | head -1 | awk '{print substr($3,1,1)}'`
if [ "$INFREL" = "7" ]
then
INPREF=on
if [ -z "$1" ]
then
${INPREF}stat -d | awk '
BEGIN { i=0 }
/^Dbspaces/ { i=1 ; getline; next}
NF<6 { i=0 ; next}
i==1 {
printf "0x%0.3X\\t%s\\n", $2, $NF
}
'
else
${INPREF}stat -d | awk '
BEGIN { i=0 }
/^Dbspaces/ { i=1 ; getline; next}
NF<6 { i=0 ; next}
i==1 {
printf "0x%0.3X\\t%s\\n", $2, $NF
}
' | grep $1 | awk '{print $2}'
fi
else
INPREF=tb
if [ -z "$1" ]
then
${INPREF}stat -d | awk '
BEGIN { i=0 }
/^Dbspaces/ { i=1 ; getline; next}
NF<6 { i=0 ; next}
i==1 {
printf "0x%0.2X\\t%s\\n", $2, $NF
}
'
else
${INPREF}stat -d | awk '
BEGIN { i=0 }
/^Dbspaces/ { i=1 ; getline; next}
NF<6 { i=0 ; next}
i==1 {
printf "0x%0.2X\\t%s\\n", $2, $NF
}
' | grep $1 | awk '{print $2}'
fi
fi
--
Paul White
paulwh@masterpiece.alphalink.com.au
Richard Thomas <Richard.Thomas@yes.optus.com.au> wrote in article
<6s3120$des$1@news.xmission.com>...
>
> Susan:
>
> You're right, it sure ain't obvious. I am presuming you don't use
> fragmentation (mainly from your post the other day), so you can use the
> following:
>
> SELECT tabname, DBINFO('dbspace', partnum) AS dbsname
> FROM systables
> WHERE partnum > 0
> AND tabid > 99>
> If you do use fragmentation, the query is much the same, but you need to
> look at the partn column of sysfragments for the part numbers.
>
> And of course, all of this is presuming you have version 7+.
>
> Hope that helps
>
> RET
> > ----------
> > From: Susan Elliott (ISG)
> > Sent: Thursday, 27 August 1998 2:39 PM
> > To: 'Informix Mailing List'
> > Subject: Q: Another how to question
> >
> > Howdy folks,
> >
> > I have a simple need to know the tabname and what dbspace name it is
> > in...
> >
> > I have pored over the sys tables, and I haven't spotted anything that
> > will tell me this. Does anyone have a simple query that will tell me
> > this... or able to lead me in the right direction....
> >
> > TIA
> >
> > Suze.
> >
>