2016-04-18 11 views
0

Ich möchte den Speicherplatz und den verbleibenden Speicherplatz programmatisch abfragen. Wie kann ich das in der dashDB?wie Abfrage Datenträger verwendet/verfügbar auf dashDB

In Orakel, kann ich so etwas wie dies auszuführen:

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; 

Wie würde ich mit dashDB ähnlich tun?

+0

select substr (a.tabname, 1,30), (a.fpages * Seitengröße/1024) als size_k, a.card von syscat.tables a, b, wo SYSCAT.TABLESPACES a.TBSPACEID = b.TBSPACEID ; SELECT TABSCHEMA, TABNAME, SUMME (DATA_OBJECT_P_SIZE) + SUMME (INDEX_OBJECT_P_SIZE) + SUMME (LONG_OBJECT_P_SIZE) + SUMME (LOB_OBJECT_P_SIZE) + SUMME (XML_OBJECT_P_SIZE) FROM SYSIBMADM.ADMINTABINFO-Gruppe von tabschema, tabname; –

Antwort

1

Eine einfache und schnelle Methode ist es, in den Katalog zu schauen, der schließlich auf dem neuesten Stand ist (es gibt statistische Sammlungen in bestimmten Intervallen, wenn die Katalogtabellen aktualisiert werden mit aktuellen Statistiken):

select substr (a.tabname, 1,30), (a.fpages * Seitengröße/1024) als size_k, a.card von syscat.tables a, b SYSCAT.TABLESPACES, wo ein .TBSPACEID = b.TBSPACEID;

Eine genauere, aber kostspielige Methode ist folgende:

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 wobei tabschema = '' und tabname = '' group by tabschema, tabname;

1

Zur Zeit gibt es keinen API-Aufruf dafür. (Hier finden Sie die verfügbaren API-Aufrufe: https://developer.ibm.com/clouddataservices/docs/dashdb/rest-api/) Zu diesem Zeitpunkt können Sie nur über die DashDB-Benutzeroberfläche feststellen, wie viel Speicherplatz Sie verwenden oder noch haben. Das DashDB-Team erforscht zusätzliche Möglichkeiten, die ich kenne. Ich poste hier noch einmal, wenn ich mehr weiß