如何查询dashDB上使用/可用的磁盘

时间:2016-04-18 08:49:36

标签: dashdb

我想以编程方式查询使用的磁盘空间和剩余空间。我怎样才能在dashDB中执行此操作?

在oracle中,我可以执行以下操作:

column dummy noprint
column  pct_used format 999.9               heading "%|Used"
column  name    format a16                  heading "Tablespace Name"
column  bytes   format 9,999,999,999,999    heading "Total Bytes"
column  used    format 99,999,999,999       heading "Used"
column  free    format 999,999,999,999      heading "Free"
break   on report
compute sum of bytes on report
compute sum of free on report
compute sum of used on report

set linesize 132
set termout off
select a.tablespace_name                                              name,
       b.tablespace_name                                              dummy,
       sum(b.bytes)/count( distinct a.file_id||'.'||a.block_id )      bytes,
       sum(b.bytes)/count( distinct a.file_id||'.'||a.block_id ) -
       sum(a.bytes)/count( distinct b.file_id )                       used,
       sum(a.bytes)/count( distinct b.file_id )                       free,
       100 * ( (sum(b.bytes)/count( distinct a.file_id||'.'||a.block_id )) -
               (sum(a.bytes)/count( distinct b.file_id ) )) /
       (sum(b.bytes)/count( distinct a.file_id||'.'||a.block_id ))    pct_used
from sys.dba_free_space a, sys.dba_data_files b
where a.tablespace_name = b.tablespace_name
group by a.tablespace_name, b.tablespace_name;

我如何与dashDB类似?

2 个答案:

答案 0 :(得分:1)

目前没有针对此的API调用。 (在此查找可用的API调用:https://developer.ibm.com/clouddataservices/docs/dashdb/rest-api/)此时,通过dashDB UI了解您正在使用或剩余的空间的唯一方法。我知道,dashDB团队正在探索其他可能性。如果我了解更多,我会再次在这里发帖

答案 1 :(得分:1)

一个简单而快速的方法是查看目录,该目录最终是最新的(当使用最新统计数据更新目录表时,在某些时间间隔内部完成统计集合):

  

选择substr(a.tabname,1,30),(a.fpages * PAGESIZE / 1024)作为size_k,a.card来自syscat.tables a,syscat.tablespaces b其中a.TBSPACEID = b.TBSPACEID; < / p>

这是一个更准确但成本更高的方法:

  

SELECT TABSCHEMA,TABNAME,SUM(DATA_OBJECT_P_SIZE)+ SUM(INDEX_OBJECT_P_SIZE)+ SUM(LONG_OBJECT_P_SIZE)+ SUM(LOB_OBJECT_P_SIZE)+ SUM(XML_OBJECT_P_SIZE)FROM SYSIBMADM.ADMINTABINFO其中tabschema =&#39;&#39;和tabname =&#39;&#39;按tabchema,tabname;

分组