Wednesday 14 October 2015

oracle script to check the database growth

SET LINESIZE 200
SET PAGESIZE 200
COL "Database Size" FORMAT a13
COL "Used Space" FORMAT a11
COL "Used in %" FORMAT a11
COL "Free in %" FORMAT a11
COL "Database Name" FORMAT a13
COL "Free Space" FORMAT a12
COL "Growth DAY" FORMAT a11
COL "Growth WEEK" FORMAT a12
COL "Growth DAY in %" FORMAT a16
COL "Growth WEEK in %" FORMAT a16
SELECT
(select min(creation_time) from v$datafile) "Create Time",
(select name from v$database) "Database Name",
ROUND((SUM(USED.BYTES) / 1024 / 1024 ),2) || ' MB' "Database Size",
ROUND((SUM(USED.BYTES) / 1024 / 1024 ) - ROUND(FREE.P / 1024 / 1024 ),2) || ' MB' "Used Space",
ROUND(((SUM(USED.BYTES) / 1024 / 1024 ) - (FREE.P / 1024 / 1024 )) / ROUND(SUM(USED.BYTES) / 1024 / 1024 ,2)*100,2) || '% MB' "Used in %",
ROUND((FREE.P / 1024 / 1024 ),2) || ' MB' "Free Space",
ROUND(((SUM(USED.BYTES) / 1024 / 1024 ) - ((SUM(USED.BYTES) / 1024 / 1024 ) - ROUND(FREE.P / 1024 / 1024 )))/ROUND(SUM(USED.BYTES) / 1024 / 1024,2 )*100,2) || '% MB' "Free in %",
ROUND(((SUM(USED.BYTES) / 1024 / 1024 ) - (FREE.P / 1024 / 1024 ))/(select sysdate-min(creation_time) from v$datafile),2) || ' MB' "Growth DAY",
ROUND(((SUM(USED.BYTES) / 1024 / 1024 ) - (FREE.P / 1024 / 1024 ))/(select sysdate-min(creation_time) from v$datafile)/ROUND((SUM(USED.BYTES) / 1024 / 1024 ),2)*100,3) || '% MB' "Growth DAY in %",
ROUND(((SUM(USED.BYTES) / 1024 / 1024 ) - (FREE.P / 1024 / 1024 ))/(select sysdate-min(creation_time) from v$datafile)*7,2) || ' MB' "Growth WEEK",
ROUND((((SUM(USED.BYTES) / 1024 / 1024 ) - (FREE.P / 1024 / 1024 ))/(select sysdate-min(creation_time) from v$datafile)/ROUND((SUM(USED.BYTES) / 1024 / 1024 ),2)*100)*7,3) || '% MB' "Growth WEEK in %"
FROM    (SELECT BYTES FROM V$DATAFILE
UNION ALL
SELECT BYTES FROM V$TEMPFILE
UNION ALL
SELECT BYTES FROM V$LOG) USED,
(SELECT SUM(BYTES) AS P FROM DBA_FREE_SPACE) FREE
GROUP BY FREE.P;

Output:



20 comments:

  1. Amit,
    Can you include monthly growth asweel in the script.

    ReplyDelete
  2. Congrats for your script. Brilliant.

    ReplyDelete
  3. Hi Amit,
    your script very good. Can help to include monthly growth as well in your script?

    Thanks

    ReplyDelete
  4. Hi Amit, Its really a big help

    ReplyDelete
  5. Thanks Amit !!!
    Its Really superb query .. Could you please add monthly in this script ?

    ReplyDelete
  6. Can we insert data in one table for database growth from multiple databases?

    ReplyDelete
  7. Great thankyou..

    ReplyDelete
  8. Thanks...helped today.

    -Satya
    http://satya-dba.blogspot.com/

    ReplyDelete
  9. Not a correct script, assumption is made on used space divided by min creation time of datafile , like when first db file is created is the first day, division of these two parameters won't give accurate daily or weekly growth.

    ReplyDelete
  10. Do you have the correct script. Thanks

    ReplyDelete
  11. Growth monitoring is the regular measurement of a child's size (weight, height or length and head circumference) in
    order to document growth. The child's size measurementsmust then be plotted on a growth chart.
    This is extremely important as
    it can detect early changes in a child's growth

    ReplyDelete
  12. i need Oracle script to check the database growth in last 7 days.

    ReplyDelete
  13. Your blog is in a convincing manner, thanks for sharing such an information with lots of your effort and time
    sql server dba online training
    sql dba training

    ReplyDelete
  14. Iam so thrilled because of finding your alluring website here.Actually i was searching for Oracle CPQ BML.Your blog is so astounding and informative too..Iam very happy to find such a creative blog. Iam also find another one by mistake while am searching the same topic Oracle PPM Cloud.Thank you soo much.

    ReplyDelete
  15. Iam so thrilled because of finding your alluring website here.Actually i was searching for Oracle CPQ BML.Your blog is so astounding and informative too..Iam very happy to find such a creative blog. Iam also find another one by mistake while am searching the same topic Oracle PPM Cloud.Thank you soo much.

    ReplyDelete
  16. COL BEGIN_INTERVAL_TIME FORMAT A30
    COL END_INTERVAL_TIME FORMAT A30

    SELECT BEGIN_INTERVAL_TIME,END_INTERVAL_TIME,B.NAME,
    ROUND((TABLESPACE_SIZE*16*1024)/1024/1024,2) SIZE_MB,
    ROUND((TABLESPACE_MAXSIZE*16*1024)/1024/1024,2) MAXSIZE_MB,
    ROUND((TABLESPACE_USEDSIZE*16*1024)/1024/1024,2) USEDSIZE_MB
    FROM DBA_HIST_TBSPC_SPACE_USAGE A
    JOIN V$TABLESPACE B ON (A.TABLESPACE_ID = B.TS#)
    JOIN DBA_HIST_SNAPSHOT C ON (A.SNAP_ID = C.SNAP_ID)
    WHERE NAME = 'D5_SLS_DAY_STR_UPC'
    ORDER BY 1 ASC;

    ReplyDelete
  17. Top 5 solo titanium razor tips for beginners! - Titanium Arts
    › tips › tips Here's our 5 tips to help omega titanium beginners micro titanium trim learn titanium nose hoop the ins and outs of the top 10 beginner razor tips for beginners to make your next beginner titanium mig 170 razor titanium white fennec

    ReplyDelete