*Fala Chiappa!!!*

*Eu entendi, só estou tentando combinar essa soma do MAXSIZE que está
na mgmt$db_datafiles com as demais informações que está
na mgmt$db_tablespaces para obter as informações abaixo:*


         (Mb)         (Mb)         (Mb)           (%)             (Mb)
   (Mb)       (%)      (%)
        Total         Used         Free           Free       Maxsize
Maxfree Maxfree Used>80%
      ------------       ------------   ------------      -------
 ------------       ------------    -------   --------
     262371.0      144327.0    118044.0     45.0     393215.0     248888.0
  63.3
     171658.0       52599.0     119059.0     69.4     327679.0
 275080.0    83.9
              2.0                .0             2.0     96.9      32767.0
    32767.0   100.0
         1024.0              1.0       1023.0      99.9      32767.0
32766.0   100.0
         1024.0              1.0       1023.0      99.9      32767.0
32766.0   100.0
      530426.0     358463.0     171963.0    32.4     557055.0     198592.0
  35.7
        65536.0      28280.0      37256.0      56.8      65536.0
 .0          .0
      103837.0      19018.0      84819.0      81.7     111005.0
91987.0    82.9

*Esse gráfico eu consigo tirar pelo TOAD, e via SQL-PLUS consultando a
views dba_free_space, dba_data_files, dba_temp_files, etc.. **Com esse
script aqui:*

select xy.tablespace_name "Tablespace Name"
     , xy.autoextend "Autoextend"
     , xy.total "Total"
     , xy.used "Used"
     , xy.free "Free"
     , xy.free_pc "%Free"
     , xy.maxsize "Maxsize"
     , xy.maxfree "Maxfree"
     , xy.maxfree_pc "%Maxfree"
     , CASE WHEN (xy.free_pc <= 20) THEN (100-xy.free_pc) END as "%Used>80%"
from (select tablespace_name
           ,
decode(sum(maxsize_total),0,decode(sum(maxsize_free),0,'N','S'),'S')
autoextend
           , round(sum(total)/1024/1024) total
           , round(sum(total)/1024/1024)-round(sum(free)/1024/1024) used
           , round(sum(free)/1024/1024)  free
           , decode(sum(total),0,0,round((sum(free)/sum(total)*100),1))
free_pc
           ,
decode(sign(15-decode(sum(total),0,0,round(sum(free)/sum(total)*100,1))),1,'Atencao')
status
           , round(sum(maxsize_total)/1024/1024) maxsize
           , round(sum(maxsize_free)/1024/1024) maxfree
           ,
decode(sum(maxsize_total),0,0,round((sum(maxsize_free)/sum(maxsize_total)*100),1))
maxfree_pc
      from (
select tablespace_name
       , 0 total
   , sum(bytes) free
   , 0 maxsize_total
   , sum(bytes) maxsize_free
            from dba_free_space
            group by tablespace_name
            union
            select tablespace_name,
   sum(bytes) total,
   0 free,

 
sum(decode(autoextensible,'YES',decode(sign(maxbytes-bytes),-1,bytes,maxbytes),'NO',bytes))
maxsize_total,

 
sum(decode(autoextensible,'YES',decode(sign(maxbytes-bytes),-1,0,maxbytes-bytes),'NO',0))
maxsize_free
            from dba_data_files
            group by tablespace_name
            union
            select a.tablespace_name,
       a.bytes total,
   nvl((a.bytes-t.bytes_used),a.bytes) free,
                   a.maxsize_total,
   a.maxsize_free
            from (
  select tablespace_name
  , sum(bytes) bytes
  ,
sum(decode(autoextensible,'YES',decode(sign(maxbytes-bytes),-1,bytes,maxbytes),'NO',bytes))
maxsize_total
  ,
sum(decode(autoextensible,'YES',decode(sign(maxbytes-bytes),-1,0,maxbytes-bytes),'NO',0))
maxsize_free
  from dba_temp_files
  group by tablespace_name
     ) a,
                 (
select tablespace_name
, sum(bytes_cached) bytes_used
                  from v$temp_extent_pool
                  group by tablespace_name
  ) t
            where a.tablespace_name = t.tablespace_name(+)
)
      group by tablespace_name
      having tablespace_name like upper(nvl(null,'%')) ) xy
order by 1;

*No SYSMAN as informações das **views dba_free_space, dba_data_files,
dba_temp_files,
estão agrupadas nas views: **mgmt$db_datafiles e ** mgmt$db_tablespaces. *

*Uma parte da consulta já está funcionando e as informações estão batendo
com o banco de dados, utilizando somente as informações da *
*mgmt$db_tablespaces**, agora falta esse maxsize que está na
**mgmt$db_datafiles,
já tentei com join mas a soma não está batendo com a consulta do TOAD, com
o UNION está batendo, mas não consigo retirar os registros duplicados.*

TB_STATS     TB_TOTAL   TB_USADO   TB_LIVRE    TB_PERC
----------            ----------         ----------          ----------
       ----------
ONLINE          262371          144455         117916           44.9
ONLINE         171658             52658        119000            69.3
ONLINE              2                  0                    2
 96.9

Só não estou conseguindo incluir o MAXSIZE que está na *mgmt$db_datafiles.*




<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Livre
de vírus. www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>.
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

Em 6 de fevereiro de 2018 18:45, [email protected] [oracle_br] <
[email protected]> escreveu:

>
>
> Bom, primeiro eu tenho que indicar que 'maxsize de uma tablespace' é algo
> que Não EXISTE : uma tablespace é formada por N datafiles, e CADA UM DESSES
> DATAFILES possui o SEU próprio MAXISZE... E inclusive, NADA IMPEDE que na
> mesma tablespace vc tenha um datafile A que é AUTOEXTEND SEM LIMITEs, um
> datafile B que Não é autoextend e um datafile C que é AUTOEXTEND com
> MAXSIZE de x bytes... OKDOC ?? IDEM para eventuais stats de Free e Used,
> isso é POR DATAFILE, yep ???
>
>  Com isso Explicado, meu primeiro PALPITE é que a tua query tá trazendo a
> informação POR DATAFILE,assim portanto  NÂO TEM "DUPLICAÇÃO" NENHUMA, tipo
> (nesse meu 'exemplo'):
>
>  TB_NAME  DATAFILE   TB_USADO TB_LIVRE MAX_SIZE
>  X        DATAFILE_A      100      nn  UNLIMITED
>           DATAFILE_B      200      xx  200
>           DATAFILE_C      300      zz  300
>
> Sim sim ?? Manda então uma query INCLUINDO O DATAFILE para Comprovar ou
> Disprovar isso....
>
> SE for tal como eu estou dizendo, aí é com você : existem N métodos para
> vc 'agrupar' linhas, normalmente fazendo um SUM nas colunas numéricas...
> Por exemplo, vc pode usar Analytics fazendo uma SOMA na coluna MAX_SIZE
> agrupado por TABLESPACE_NAME, ou mesmo um GROUP BY...
>
> mas antes de mais nada PLEASE faz a query INCLUINDO os datafiles pra gente
> Confirmar ou Negar que os valores nessas tabelas aí são POR DATAFILE...
>
> []s
>
>   Chiappa
> 
>

Responder a