[Oracle] Information about the size of the database

Last update on July 31, 2009 12:42 PM by jak58
Published by jak58

[Oracle] Information about the size of the database






Normally the size of the database is denoted by total size of the physical datafiles.
This query will help you to manage the space occupied by your database.


clear breaks
clear computes
clear columns
set pagesize 50
set linesize 120
set heading on
column tablespace_name heading 'Tablespace' justify left format a20 truncated
column tbsize heading 'Size|(Mb) ' justify left format 9,999,999.99
column tbused heading 'Used|(Mb) ' justify right format 9,999,999.99
column tbfree heading 'Free|(Mb) ' justify right format 9,999,999.99
column tbusedpct heading 'Used % ' justify left format a8
column tbfreepct heading 'Free % ' justify left format a8
break on report
compute sum label 'Totals:' of tbsize tbused tbfree on report
select t.tablespace_name, round(a.bytes,2) tbsize,
nvl(round(c.bytes,2),'0') tbfree,
nvl(round(b.bytes,2),'0') tbused,
to_char(round(100 * (nvl(b.bytes,0)/nvl(a.bytes,1)),2)) || '%' tbusedpct,
to_char(round(100 * (nvl(c.bytes,0)/nvl(a.bytes,1)),2)) || '%' tbfreepct
from dba_tablespaces t,
(select tablespace_name, round(sum(bytes)/1024/1024,2) bytes
from dba_data_files
group by tablespace_name
union
select tablespace_name, round(sum(bytes)/1024/1024,2) bytes
from dba_temp_files
group by tablespace_name ) a,
(select e.tablespace_name, round(sum(e.bytes)/1024/1024,2) bytes
from dba_segments e
group by e.tablespace_name
union
select tablespace_name, sum(max_size) bytes
from v$sort_segment
group by tablespace_name) b,
(select f.tablespace_name, round(sum(f.bytes)/1024/1024,2) bytes
from dba_free_space f
group by f.tablespace_name
union
select tmp.tablespace_name, (sum(bytes/1024/1024) - sum(max_size)) bytes
from dba_temp_files tmp, v$sort_segment sort
where tmp.tablespace_name = sort.tablespace_name
group by tmp.tablespace_name) c
where
t.tablespace_name = a.tablespace_name (+)
and t.tablespace_name = b.tablespace_name (+)
and t.tablespace_name = c.tablespace_name (+)
order by t.tablespace_name



Thanks to wjaouadi for the code!!
Best answers for « Information about the size of the database » in :
Backing up the database managed by the user Show Backing up the database managed by the user 1. Query views for information on database files Use the view V$DATAFILE to obtain a list of names and statements of all data files Use the V$CONTROLFILE to display all the control files...
Introduction - Databases Show What is a database? A database (abbreviated DB) is an entity in which data can be stored in a structured manner, with as little redundancy as possible. Different programs and different users must be able to use this data. Therefore, the concept of...
Reducing a Jpg image size ShowReducing a Jpg image size Step 1 (optional!): Skip GREYCstoration on the image Step 2: Reduce the resolution Step 3: Lower quality Step 4: Remove unnecessary information Conclusion If you find that your JPEG files are too large...
Display name of the Oracle database ShowDisplay name of the Oracle database To view the name of the Oracle databases and data related to them, simply run the command: SELECT * FROM V$DATABASE;
[Virus] System Volume Information Show[Virus] System Volume Information The System Volume Information folder is used by Windows XP for storing data on system configuration and is also used by the System Restore tool to store information and restore points. Restore points...
Database administrator ShowDatabase administrator A database administrator (or DBA for short) is in charge of maintaining and operating the databases which form a company's information system. Skills Given the critical nature of the data he/she is in charge of, the...
DBMS models ShowThe various database models Databases appeared in the late 1960s, at a time when the need for a flexible information management system had arisen. There are five models of DBMS, which are distinguished based on how they represent the data...
Information System ShowConcept of an Information System A company creates value by processing information, particularly in the case of service companies. So, information has a much greater value because it contributes to achieving the company's objectives. An...