小智 9
select
a.CARD*(sum(b.AVGCOLLEN)+10)/1024/1024 as Tablesize_in_MB
from
syscat.tables as a, syscat.columns as b
where
a.TABNAME = b.TABNAME and b.TABNAME = 'TABLE_NAME' group by a.CARD
Run Code Online (Sandbox Code Playgroud)
select
char(date(t.stats_time))||' '||char(time(t.stats_time)) as statstime
,substr(t.tabschema,1,8)||'.'||substr(t.tabname,1,24) as tabname
,card as rows_per_table
,decimal(float(t.npages)/ ( 1024 / (b.pagesize/1024)),9,2) as used_mb
,decimal(float(t.fpages)/ ( 1024 / (b.pagesize/1024)),9,2) as allocated_mb
from
syscat.tables t , syscat.tablespaces b
where t.tbspace=b.tbspace
order by 5 desc with ur
Run Code Online (Sandbox Code Playgroud)
select
rtrim(substr(i.tabschema,1,8))||'.'||rtrim(substr( i.tabname, 1,24)) as tabname
,decimal(sum(i.nleaf)/( 1024 / (b.pagesize/1024)),12,2) as indx_used_per_table_mb
from
syscat.indexes i, syscat.tables t , syscat.tablespaces b
where
i.tabschema is not null and i.tabname=t.tabname
and i.tabschema=t.tabschema and t.tbspace=b.tbspace
group by
i.tabname,i.tabschema, b.pagesize order by 2 desc with ur
Run Code Online (Sandbox Code Playgroud)
您的问题造成了错误的二分法,因为可能在不向表空间分配有限空间的情况下创建了表空间。限制可能是表空间所在的驱动器或共享。但是,如果您知道分配给表空间的空间,或者只需要表正在使用的表空间当前大小的百分比,那么可以的话,有一种方法可以知道。
SELECT * FROM SYScat.tables where tabname='mytable';
Run Code Online (Sandbox Code Playgroud)
会告诉您表格正在使用多少页。
然后在命令行:LiST TABLESPACES SHOW DETAIL
将告诉您表空间中的总页数以及页的大小(以字节为单位)。
Select * from sysibmadm.tbsp_utilization where tbsp_name='MyTblSpace'
Run Code Online (Sandbox Code Playgroud)
如果有一个表空间,它将为您提供最大的表空间大小。