Re: How to determine a db's dbpace?
Posted in 1994
In article <34o1oj$ck6@laugh.agcs.com> tomasr@agcs.com (Roger Tomas) writes: >Anyone know how to determine a database's dbspace in a manner >that can be done from a UNIX shell script? I need to create >a shell script that creates a database in the same dbspace as >a related database but cannot make any assumptions about which >dbspace that might be. > You need to find the hex(partnum) of a system catalog, and find the dbspace that corresponds to the first half of the word. I do it as follows: get_dbspacenum_t () { DBSPACENUM=`echo " output to pipe cat without headings select hex(partnum) from systables where tabname = \\"${1?}\\" " | isql $DBNAME 2>&- | awk ' /0/ {print substr($0,4,1)}'` } I get the free space for it this way - get_dbspace_free () { DBSPACEFREE=`tbstat -d | awk ' /pathname/ { while (getline) if ( $3 == "'${DBSPACENUM?}'" ) FREE+=$6 } END { print FREE }'` } I thought I had something to dig out the spacename as well but - I dont, so I guess you can take it from there.