22 September 2009

Informix: What tables is in each dbspace?

SQL บน Informix ที่ไว้หาว่าแต่ละ dbspace มี table อะไรอาศัยอยู่บ้าง

dbaccess {dbname}
select
dbinfo( "DBSPACE" , pe_partnum ) :: char(10) as dbspace
,b.dbsname[1,10] dbsname
,b.tabname[1,30] objname
,case when c.tabid is null then 'i' else 't' end as objtp
from
sysmaster@{instancename}:sysptnext a
, sysmaster@{instancename}:systabnames b
, outer {dbname}@{instancename}:systables c
where
a.pe_partnum = b.partnum
and b.tabname = c.tabname
and b.tabname not like 'sys%'
and b.dbsname='{dbname}'
and dbinfo( "DBSPACE" , pe_partnum ) :: char(10) = '{dbspacename}'
group by 1,2,3,4
order by 1,2,3,4;