Re: How to get dbspace for a table???
Posted in 1994
In article <1994Oct30.160211.774@lmpsbbs.comm.mot.com> ennis@ssd.comm.mot.com (Bill Ennis) writes: >I am trying to get th dbspace which a table is resident to. >Does anyone know how to do this? (either through systable lookup >or through an Informix utility? ><Using Informix version 4.10> > Some of you may recognize this as a repeat post - if anyone modified this to work better genericly than below, which is specific to my environment, please follow up - The following shell named function (you can reduce it to the basic sql yourself) takes as input a tablename, needs to have a DBNAME defined, and returns the dbspacenum, which is the first part of the partnum in systables: get_dbspacenum_t () { DBSPACENUM=`echo " output to pipe cat without headings select hex(partnum) from systables where tabname = \\"${1?}\\" " | isql $CLSI_DBNAME 2>&- | awk ' /0/ {print substr($0,4,1)}'` } The following function takes are input the text name of a dbspace, and returns its dbspacenumber. I dont seem to have anything that reverses this, knows a dbspacenum and returns the text name. get_dbspacenum_d () { DBSPACENUM=`tbstat -d|awk "/${1?}db/"' {print $2}'` } The following totals the freespace for a dbspace. With modification it could take the dbspacenum and return the dbspacename. get_dbspace_free () { DBSPACEFREE=`tbstat -d | awk ' /pathname/ { while (getline) if ( $3 == "'${DBSPACENUM?}'" ) FREE+=$6 } END { print FREE }'` }