Home > Oracle Tips > Oracle Database Administrator > Determine database size
Oracle Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ORACLE DATABASE ADMINISTRATOR

Determine database size


vijay kaushik
10.12.2003
Rating: -3.04- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


This script reports the following:

  • the names of all tablespaces
  • the datafiles and locations that are associated with the tablespaces
  • the size of each tablespace
  • the amount of used and free space in each tablespace (which is also represented as a percentage)
It has been tested on versions 8 and up. Log in as a user with DBA privileges or as SYS or SYSTEM to run this script.
 declare
  dbname VARCHAR2(8);
  CURSOR c1 IS
  SELECT tablespace_name, file_id, max(bytes)
 largeextent,
  sum(bytes) totalfreespace
  FROM sys.dba_free_space
  GROUP BY tablespace_name, file_id
  ORDER BY tablespace_name, file_id;
 
  CURSOR c2 (fileid INTEGER) IS
  SELECT name, bytes
  FROM v$datafile
  WHERE file# = fileid;
 
  BEGIN
  SELECT name INTO dbname  FROM v$database;
  DBMS_OUTPUT.PUT_LINE('');
  DBMS_OUTPUT.PUT_LINE('Space Report for Database
 '||dbname);
 

DBMS_OUTPUT.PUT_LINE('-----------------------------------');
  DBMS_OUTPUT.PUT_LINE('');
  
  FOR rec1 IN c1
  LOOP
  DBMS_OUTPUT.PUT_LINE('Tablespace Name:        
 '||rec1.tablespace_name);
  DBMS_OUTPUT.PUT_LINE('');
  
 FOR rec2 IN c2  (rec1.file_id)
 LOOP
 DBMS_OUTPUT.PUT_LINE('Data File Name:           '   
   
 ||rec2.name);
 DBMS_OUTPUT.PUT_LINE('Total File Size (MB):     '
 ||ROUND(rec2.bytes/1024/1024,0));
 DBMS_OUTPUT.PUT_LINE('Free Space in File (MB):  '
 ||ROUND(rec1.totalfreespace/1024/1024,0));
 DBMS_OUTPUT.PUT_LINE('% Free Space in File:     '   
  ||ROUND
 (((rec1.totalfreespace/rec2.bytes)*
 100),0)||'%');
 DBMS_OUTPUT.PUT_LINE('Largest Extent (MB):      '
 ||ROUND(rec1.largeextent/1024/1024,0));
 DBMS_OUTPUT.PUT_LINE('');
 END LOOP;
 END LOOP;
 END;
 /

For More Information

  • Feedback: E-mail the editor with your thoughts about this tip.
  • More tips: Hundreds of free Oracle tips and scripts.
  • Tip contest: Have an Oracle tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize -- submit your tip today!
  • Ask the Experts: Our applications, SQL, database administration, and data warehousing gurus are waiting to answer your toughest questions.
  • Forums: Ask your technical Oracle questions--or help out your peers by answering them--in our active forums.
  • Best Web Links: Oracle tips, tutorials, and scripts from around the Web.

Rate this Tip
To rate tips, you must be a member of SearchOracle.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
Oracle Database Administrator
What is the difference between a database engineer, architect and administrator?
Import on one table from dump file
Error during RMAN backup
Can I drop a column in SYS schema?
STATSPACK tool: transaction vs. execution measurement
Should I port from Microsoft Access?
Installing multiple Oracle homes
How can I find statistics on total memory usage and database connections?
Modifying SYS password in a RAC environment
How to create Datafiles in a Data Guard (10g) environment

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.

HomeNewsTopicsTipsAsk the ExpertsMultimediaWhite PapersProductsBlogs
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2003 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts