Script to check database growth per month


Script to check  database growth per month :

=========================================================

Abstract
This script will report the details of database growth per month.

Execution Environment: 
Any client environment which can connect to database and execute SQL. For example, SQL*plus, iSQL*plus.

Required Privileges:
Need select privilege on sys.v_$datafile view.

Usage: 
Save main script in a file named DB_GROWTH_PER_MONTH.SQL. Then,
if you are outside sqlplus then issue,
$ sqlplus username/password @DB_GROWTH_PER_MONTH.SQL
or if you are inside sqlplus then issue,
SQL> @DB_GROWTH_PER_MONTH.SQL

Instructions to use:
Copy the codes into a file named DB_GROWTH_PER_MONTH.SQL and run that script.

Description of the Script
The script will report the total size of all datafiles, grouped by the month in which they
were created. Note that, this script will report based on CREATION_TIME column of V$DATAFILE/V_$DATAFILE view which holds the timestamp of the datafile creation. So if you don't have datafile created in a month you will not get information of that month.

Sample Input:
No input is required as it will report based on datafile in the database.

Sample Output:
Month          Growth in MB
-------------- ------------
2010 November             2
2010 October            100

Main Script
select to_char(creation_time, 'YYYY Month') "Month",
    sum(bytes)/1024/1024 "Growth in MB"
    from sys.v_$datafile
    where creation_time > SYSDATE-365
    group by to_char(creation_time, 'YYYY Month'); 

Execution Result
SQL> start "E:\All Projects\Arju\Scripts\DB_GROWTH_PER_MONTH.SQL"

Month          Growth in MB
-------------- ------------
2010 November             2
2010 October            100

No comments: