Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Divisor is equal to zero

Re: Divisor is equal to zero

From: SL <sebastien-louchart_at_wanadoo.fr>
Date: 21 Sep 2006 02:35:36 -0700
Message-ID: <1158831336.661883.41000@h48g2000cwc.googlegroups.com>

muddu a écrit :

> Hello,
>
> I am running a sql script to determine how much % the tablespaces are
> occupying.
> But I am getting this error:
>
> ERROR at line 3:
> ORA-01476: divisor is equal to zero
>
> line 3: round(100 * (us.usedspace / df.totalspace)) per.

Although I do agree with Sybrand, I provide you with a query I use personnally :

select
U.tablespace_name tbs,nvl(U.used,0) used ,nvl(F.free,0) free, nvl(U.used,0)+nvl(F.free,0) total,
round(100*(nvl(U.used,0)/(nvl(U.used,0)+nvl(F.free,0))),1) pct_used, round(100*(nvl(F.free,0)/(nvl(U.used,0)+nvl(F.free,0))),1) pct_free from
(select v1.tablespace_name,round(sum(v2.bytes/1024/1024),3) used  from dba_tablespaces v1,

      dba_segments v2
 where v1.tablespace_name=v2.tablespace_name(+)    and v1.contents <> 'TEMPORARY' and v1.status<>'OFFLINE'  group by v1.tablespace_name) U,
 (select v1.tablespace_name, round(sum(v3.bytes/1024/1024),3) free   from dba_tablespaces v1,

       DBA_FREE_SPACE v3
  where v1.tablespace_name=v3.tablespace_name(+)   and v1.contents <> 'TEMPORARY' and v1.status<>'OFFLINE'     group by v1.tablespace_name) F
where F.tablespace_name=U.tablespace_name;

The criteria <> 'TEMPORARY' and <>'OFFLINE' prevent you from getting 0 values as divisor.

HTH

-- 
SL
Received on Thu Sep 21 2006 - 04:35:36 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US