Hi all,
Here we'll see how do we check the free space and used space of each datafile separately in the tablespace as i said in previous post
We can use the below query to check the space usage of each and every data file in the tablespaces.
break on report
compute sum of allocated_mb on report
compute sum of used_mb on report
compute sum of free_space_mb on report
set lines 500
COLUMN free_space_mb format 999999.90
COLUMN allocated_mb format 999999.90
COLUMN used_mb format 999999.90
col file_name for a60
SELECT SUBSTR (df.NAME, 1, 60) file_name, df.bytes / 1024 / 1024 allocated_mb,
((df.bytes / 1024 / 1024) - NVL (SUM (dfs.bytes) / 1024 / 1024, 0))
used_mb,
NVL (SUM (dfs.bytes) / 1024 / 1024, 0) free_space_mb
FROM v$datafile df, dba_free_space dfs
WHERE df.file# = dfs.file_id(+) and dfs.TABLESPACE_NAME='_DATA'
GROUP BY dfs.file_id, df.NAME, df.file#, df.bytes
ORDER BY file_name;
Output:
The output is taken for one tablespace (_DATA) which contains 16 datafiles in it. So you can know the used space, free space and its allocated space of datafiles separately.
Here we'll see how do we check the free space and used space of each datafile separately in the tablespace as i said in previous post
We can use the below query to check the space usage of each and every data file in the tablespaces.
break on report
compute sum of allocated_mb on report
compute sum of used_mb on report
compute sum of free_space_mb on report
set lines 500
COLUMN free_space_mb format 999999.90
COLUMN allocated_mb format 999999.90
COLUMN used_mb format 999999.90
col file_name for a60
SELECT SUBSTR (df.NAME, 1, 60) file_name, df.bytes / 1024 / 1024 allocated_mb,
((df.bytes / 1024 / 1024) - NVL (SUM (dfs.bytes) / 1024 / 1024, 0))
used_mb,
NVL (SUM (dfs.bytes) / 1024 / 1024, 0) free_space_mb
FROM v$datafile df, dba_free_space dfs
WHERE df.file# = dfs.file_id(+) and dfs.TABLESPACE_NAME='_DATA'
GROUP BY dfs.file_id, df.NAME, df.file#, df.bytes
ORDER BY file_name;
Output:
The output is taken for one tablespace (_DATA) which contains 16 datafiles in it. So you can know the used space, free space and its allocated space of datafiles separately.
Comments
Post a Comment