Skip to content

Instantly share code, notes, and snippets.

@jzi96
Last active November 4, 2015 21:17
Show Gist options
  • Save jzi96/10446972 to your computer and use it in GitHub Desktop.
Save jzi96/10446972 to your computer and use it in GitHub Desktop.
Oracle Get Tablespace statistics
SELECT df.tablespace_name "Tablespace",
totalusedspace "Used MB",
(df.totalspace - tu.totalusedspace) "Free MB",
df.totalspace "Total MB",
ROUND(100 * ( (df.totalspace - tu.totalusedspace)/ df.totalspace)) "% Free"
FROM
(SELECT tablespace_name,
ROUND(SUM(bytes) / 1048576) TotalSpace
FROM dba_data_files
GROUP BY tablespace_name
) df,
(SELECT ROUND(SUM(bytes)/(1024*1024)) totalusedspace,
tablespace_name
FROM dba_segments
GROUP BY tablespace_name
) tu
WHERE df.tablespace_name = tu.tablespace_name
ORDER BY totalusedspace;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment