Oracle‎ > ‎SQL‎ > ‎SQL*Plus‎ > ‎

Sum Reports

-- Multiple sums with a final total
set pages 99
col gb for 99,999.000

break on tablespace_name skip 1 on report
compute sum label 'tablespace total' of gb on tablespace_name
compute sum label 'TOTAL' of gb on report

select tablespace_name, owner, round(sum(bytes)/power(1024,3),3) gb
from dba_segments
group by tablespace_name, owner
order by tablespace_name, owner;

Example output from my sandbox:

TABLESPACE_NAME                OWNER                                   GB
------------------------------ ------------------------------ -----------
EXAMPLE                        HR                                    .002
                               IX                                    .002
                               OE                                    .006
                               PM                                    .012
                               SH                                    .281
******************************                                -----------
tablespace total                                                     .303

SYSAUX                         APEX_030200                           .083
                               CTXSYS                                .004
                               DBSNMP                                .001
                               EXFSYS                                .004
                               MDSYS                                 .072
                               OLAPSYS                               .009
                               ORDDATA                               .013
                               ORDSYS                                .000
                               SYS                                   .500
                               SYSMAN                                .075
                               SYSTEM                                .013
                               WMSYS                                 .003
                               XDB                                   .123
******************************                                -----------
tablespace total                                                     .900

SYSTEM                         OUTLN                                 .001
                               SYS                                   .865
                               SYSTEM                                .015
******************************                                -----------
tablespace total                                                     .881

UNDOTBS1                       SYS                                   .012
******************************                                -----------
tablespace total                                                     .012

USERS                          EMTADMIN                              .084
                               OE                                    .003
                               SCOTT                                 .000
                               SYS                                   .008
******************************                                -----------
tablespace total                                                     .095

                                                              -----------
TOTAL                                                               2.191

26 rows selected.

Comments