Script:
To Monitor Tablespaces/datafiles
Important Note: If any of the script in this blog is not
running then please re-type it or try to retype quotation, command and braces
(may be format is changed). I am using toad so if you are using SQL then try to
fix column length before exectunig the script (if any).
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
To check Tablespace free space:
SELECT TABLESPACE_NAME, SUM(BYTES/1024/1024) "Size (MB)" FROM DBA_FREE_SPACE GROUP BY TABLESPACE_NAME;
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
To check Tablespace free space:
SELECT TABLESPACE_NAME, SUM(BYTES/1024/1024) "Size (MB)" FROM DBA_FREE_SPACE GROUP BY TABLESPACE_NAME;
To check Tablespace by datafile:
SELECT tablespace_name, File_id, SUM(bytes/1024/1024)"Size (MB)" FROM DBA_FREE_SPACE
group by tablespace_name, file_id;
To Check Tablespace used and free space %:
SELECT /* + RULE */ df.tablespace_name "Tablespace",
df.bytes / (1024 * 1024) "Size (MB)", SUM(fs.bytes) / (1024 * 1024) "Free (MB)",
Nvl(Round(SUM(fs.bytes) * 100 / df.bytes),1) "% Free",
Round((df.bytes - SUM(fs.bytes)) * 100 / df.bytes) "% Used"
FROM dba_free_space fs,
(SELECT tablespace_name,SUM(bytes) bytes
FROM dba_data_files
GROUP BY tablespace_name) df
WHERE fs.tablespace_name (+) = df.tablespace_name
GROUP BY df.tablespace_name,df.bytes
UNION ALL
Comments
Post a Comment