I had tried to show something like guage in sqlplus using RPAD trick.
Howevere, if you are running the query in sql*developer , using GUAGE will be a good way to display the graph. 
below is the  output in sql*developer and sqlplus.
| Sql*Developer OUTPUT | 
![]()  | 
| select name,con_id, bufferCache_MB, 'SQLDEV:GAUGE:0:100:0:100:' ||PCT as PCT from ( SELECT NVL(pdb.name,'CDB') name,b.con_id, ROUND(b.subtotal * (SELECT value FROM V$PARAMETER WHERE name = 'db_block_size' ) /(1024 *1024)) bufferCache_MB, ROUND(b.subtotal /b.total * 100) PCT, rpad('*',ROUND(b.subtotal/b.total * 100),'*') PCT_BARCHART FROM ( SELECT DISTINCT a.* FROM (SELECT con_id, COUNT(*) over (partition BY con_id ) subtotal , COUNT(*) over () total FROM sys.gv$bh ) a )b, v$pdbs pdb where b.con_id=pdb.con_id(+) ORDER BY con_id);  | 
| Sqlplus Output | 
![]()  | 
col PCT_BARCHART format a30 
set linesize 200 
 col name format a10 
 col con_id format 99 
 col PCT format 999 
    SELECT NVL(pdb.name,'CDB') name,b.con_id, 
  ROUND(b.subtotal *   
 (SELECT value FROM V$PARAMETER WHERE name = 'db_block_size' 
  )                        /(1024 *1024)) bufferCache_MB, 
  ROUND(b.subtotal         /b.total * 100) PCT, 
  rpad('*',ROUND(b.subtotal/b.total * 100),'*') PCT_BARCHART 
FROM 
  ( SELECT DISTINCT a.* 
  FROM 
    (SELECT con_id, 
      COUNT(*) over (partition BY con_id ) subtotal , 
      COUNT(*) over () total 
    FROM sys.gv$bh 
    ) a 
  )b, v$pdbs pdb 
  where b.con_id=pdb.con_id(+) 
ORDER BY con_id; 
 | 


No comments:
Post a Comment
Feedback welcome