Informix数据库中查询database和table占用空间的实例脚本:
#!/usr/bin/shif [ $# -ne 1 ]then echo ' Usage: dbsize.sh DBNAME ' exitfiDBNAME=$1; export DBNAMETMPFILE=/tmp/dbsize.tmpRESULT=dbsize.outexport TMPFILE RESULTdbaccess << !database sysmaster;unload to '$TMPFILE' delimiter '|'select dbsname,tabname,count(*) num_of_extents,sum( pe_size ) total_sizefrom systabnames, sysptnextwhere partnum = pe_partnum and dbsname='$DBNAME'group by 1, 2order by 3 desc, 4 desc;!awk -F '|' ' BEGIN { size=0; }{ size = size + $4}END { printf (' The Database Size of %s is %d pages. nn', ENVIRON['DBNAME'], size )}' $TMPFILE >$RESULTcat $TMPFILE >;>$RESULTview $RESULTrm -f $TMPFILE