Thursday, July 30, 2009

Database size

select dbsname DatabaseName,
trunc(sum((ti_nptotal * ti_pagesize ) / 1024/ 1024),2) || "Mb" sizeallocated,
trunc(sum((ti_npused * ti_pagesize ) / 1024/ 1024),2) || "Mb" usedsize
from sysmaster:systabinfo A, sysmaster:sysptprof B
where A.ti_partnum = B.partnum
and B.tabname not matches "TBL*" and B.dbsname not matches "*TEMP*"
and B.tabname not matches "sys*"
and B.dbsname not in ('sysmaster', 'sysutils')
group by 1

Wednesday, July 29, 2009

Table close to allocating next extent

##Table close to allocating next extent

TABLE_SPACE_FREE=10 ## as a percentage of free space

TABLE_SIZE=10 ## in mb

EXTENT_SIZE=10 ## im mb

select dbsname, DBINFO('DBSPACE', systabnames.partnum),

tabname,

( ti_nptotal * 2 ) / 1024 mb_allocated,

ti_nextns extents,

( ti_nextsiz * 2 ) / 1024 mb_nextextent,

( ti_npused * 2 ) / 1024 mb_used,

(ti_nptotal - ti_npused ) * 2 / 1024 mb_free,

((ti_nptotal - ti_npused ) * 2 / 1024 ) / (( ti_nptotal * 2 ) / 1024) * 100 pct_free

from sysmaster:systabinfo, sysmaster:systabnames

where partnum = ti_partnum

and tabname not matches 'TBL*'

and dbsname not in ('sysmaster', 'sysutils')

and ((ti_nptotal - ti_npused) * 2 / 1024 )/((ti_nptotal * 2 ) / 1024) * 100 < $TABLE_SPACE_FREE

and ( ti_nptotal * 2 ) / 1024 > $TABLE_SIZE

and ( ti_nextsiz * 2 ) / 1024 > $EXTENT_SIZE

order by 6 desc, 9 asc


Monday, July 27, 2009

Constraints de una tabla

select
c.constrname,
i.idxname,
trim(t1.tabname) || '.' || trim(col1.colname),
t2.tabname
from
systables t1,
sysconstraints c,
sysindexes i,
syscolumns col1,
sysreferences r,
systables t2
where
t1.tabid = c.tabid and
t1.tabid = i.tabid and
c.idxname = i.idxname and
t1.tabid = col1.tabid and
i.part1 = col1.colno and
c.constrid = r.constrid and
r.ptabid = t2.tabid and
t1.tabname = 'AQUI AQUI'

HDR y te cagas por la pta

sencillamente genial:

desde el primario:
ontape -s -L 0 -F -t STDIO | ssh secundario ". /informix/scripts/set_env.sh;ontape -p -t STDIO"

onmode -d sec primario

Thursday, July 9, 2009

TABNAME from partnumber

#!/bin/ksh

# Pass in partnum to give table name

echo "Partnum is: $1"

a="0x00$1"

echo "select dbsname, DBINFO('DBSPACE', systabnames.partnum),

tabname,

( ti_nptotal * 2 ) / 1024 pages_in_Mb,

( ti_npused * 2 ) / 1024 pages_used_Mb,

HEX(partnum)

from sysmaster:systabinfo, sysmaster:systabnames

where partnum = ti_partnum

and hex(partnum) = '$a'" | dbaccess sysmaster