Home > Oracle Tips > Oracle Database Administrator > Autoextend free space check
Oracle Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ORACLE DATABASE ADMINISTRATOR

Autoextend free space check


Anthony Kluyskens
06.17.2003
Rating: -4.62- (out of 5)


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


This SQL script was developed and tested on Oracle 9i but should also work on Oracle 8 versions. It checks each data file for the free space left and how much the file can grow using dba_data_files and dba_free_space. The result is joined with a similar result from dba_temp_files without the dba_free_space values because there aren't any for tempfiles.

SET LINESIZE 250
SET PAGESIZE 150

COLUMN TSNAME FORMAT A11
COLUMN FNAME FORMAT A45
COLUMN TSFREEMEGS FORMAT 9999.00
COLUMN FSIZEMEGS FORMAT 9999.00
COLUMN FMAXMEGS FORMAT 9999.00
COLUMN FDIFFMEGS FORMAT 9999.00
COLUMN TOTFREEMEGS FORMAT 9999.00

BREAK ON TSNAME SKIP 1

COMPUTE SUM LABEL TOTAL OF TSFREEMEGS ON TSNAME
COMPUTE SUM LABEL TOTAL OF FDIFFMEGS ON TSNAME
COMPUTE SUM LABEL TOTAL OF TOTFREEMEGS ON TSNAME

SELECT 
DATA.TABLESPACE_NAME "TSNAME", 
NVL(SUM(FREE.BYTES)/1024/1024 ,0) "TSFREEMEGS", 
DATA.FILE_NAME "FNAME",
DATA.BYTES/1024/1024 "FSIZEMEGS", 
DATA.MAXBYTES/1024/1024 "FMAXMEGS",
(DATA.MAXBYTES/1024/1024 - DATA.BYTES/1024/1024) "FDIFFMEGS",
NVL((SUM(FREE.BYTES)/1024/1024 + (DATA.MAXBYTES/1024/1024 - DATA.BYTES/1024/1024)),0) "TOTFREEMEGS"
FROM DBA_DATA_FILES DATA 
LEFT OUTER JOIN DBA_FREE_SPACE FREE 
ON DATA.FILE_ID = FREE.FILE_ID
GROUP BY DATA.TABLESPACE_NAME, DATA.FILE_NAME, DATA.BYTES, DATA.MAXBYTES 
UNION
SELECT 
TABLESPACE_NAME "TSNAME", 
0 "TSFREEMEGS",
FILE_NAME "FNAME",
BYTES/1024/1024 "FSIZEMEGS",
MAXBYTES/1024/1024 "FMAXMEGS",
(MAXBYTES/1024/1024 - BYTES/1024/1024) "FDIFFMEGS",
(MAXBYTES/1024/1024 - BYTES/1024/1024) "TOTFREEMEGS"
FROM DBA_TEMP_FILES
;

Reader Feedback

Michael D. writes: This SQL script was developed and tested on Oracle 9i but should also work on Oracle 8 versions. SQL92 compliant syntax is not available until Oracle 9i. The following lines should be replaced for other versions.

>>FROM DBA_DATA_FILES DATA LEFT OUTER JOIN DBA_FREE_SPACE FREE
>>ON DATA.FILE_ID = FREE.FILE_ID 

FROM DBA_DATA_FILES DATA, DBA_FREE_SPACE FREE 
WHERE DATA.FILE_ID = FREE.FILE_ID(+) 

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 SQL, database design, Oracle, SQL Server, DB2, metadata, 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.


Submit a Tip




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