replace macro all_dataspace as ( --采用宏,下次可以直接调用 select cast(trim(databasename) as char(20))||'|'(title 'name') ,cast(trim(cast(sum(currentperm)/1024/1024/1024 as int)||'G') as char(5))||'|'(title 'curr(G)') ,cast(trim(cast(sum(maxperm)/1024/1024/1024 as int)||'G')as char(6))||'|'(title 'max(G)') ,cast(trim(cast(sum(maxperm)/1024/1024/1024 as int)-cast(sum(currentperm)/1024/1024/1024 as int)||'G')as char(6))||'|'(title 'spare(G)') ,sum(currentperm)*100/nullifzero(sum(maxperm))(format 'zz9.99%',title 'per(%)') from dbc.diskspace
group by 1 order by 4 desc; );
--计算表空间 sel cast(trim(cast(sum(currentperm)/1024/1024/1024 as int)||'G') as char(5)),tablename,databasename from dbc.tablesize where databasename='dwpdata'and tablename in ('Atable','Btable','Ctable','Dtable','Etable') group by 2,3