Search
 
SCRIPT & CODE EXAMPLE
 

SQL

Oracle tablespace usage

set echo off feedback off verify off pages 75
col tablespace_name format a20 head 'Tablespace Name'
col total format 999,999,999,999 head 'Total(KB)'
col used format 999,999,999,999 head 'Used(KB)'
col free format 999,999,999,999 head 'Free(KB)'
col pct format 999 head 'Percent|Used'
break on report
compute sum of total on report
compute sum of used on report
compute sum of free on report
select    tbs.tablespace_name,
tot.bytes/1024 total,
tot.bytes/1024-sum(nvl(fre.bytes,0))/1024 used,
sum(nvl(fre.bytes,0))/1024 free,
(1-sum(nvl(fre.bytes,0))/tot.bytes)*100 pct
from      dba_free_space fre,
(select  tablespace_name, sum(bytes) bytes
from      dba_data_files
group by tablespace_name) tot,
dba_tablespaces tbs
where   tot.tablespace_name    = tbs.tablespace_name
and        fre.tablespace_name(+) = tbs.tablespace_name
group by tbs.tablespace_name, tot.bytes/1024, tot.bytes
union
select    tsh.tablespace_name,
dtf.bytes/1024 total,
sum(nvl(tsh.bytes_used,0))/1024 used,
sum(nvl(tsh.bytes_free,0))/1024 free,
(1-sum(nvl(tsh.bytes_free,0))/dtf.bytes)*100 pct
from             v$temp_space_header tsh,
(select tablespace_name, sum(bytes) bytes
from dba_temp_files
group by tablespace_name) dtf
where   dtf.tablespace_name     = tsh.tablespace_name(+)
group by tsh.tablespace_name, dtf.bytes/1024, dtf.bytes
order by 1
/
Comment

PREVIOUS NEXT
Code Example
Sql :: sql server: how to concatenate column data using comma 
Sql :: how to start my sql server on mac 
Sql :: sql alter column 
Sql :: postgresql héritage 
Sql :: sql date function 
Sql :: copy column from one table to another without column duplicate postgres 
Sql :: sqlite unix timestamp 
Sql :: sql server check for value in multiple columns 
Sql :: multiple order by sql 
Sql :: sql select most frequent value in group 
Sql :: split string and get first and last element in sql server 
Sql :: soql update query 
Sql :: postgress if 
Sql :: sql table backup 
Sql :: SQL Server OPENJSON FROM table column 
Sql :: dump multiple tables mysql 
Sql :: create postgres table 
Sql :: select only distinct values from another table and excluding from current table 
Sql :: convert negative to positive in sql 
Sql :: Select All From A Table In A MySQL Database 
Sql :: demmarrer un service mysql teminal cmd 
Sql :: sql get actual fiscal year 
Sql :: select where mysql 
Sql :: mysql join same table multiple times group by 
Sql :: collation in sql 
Sql :: Question 7: Write an SQL query to print details of the Workers who have joined in Feb’2014. 
Sql :: convert all tables in database to from myisam to innodb 
Sql :: sql where clause 
Sql :: update multiple rows 
Sql :: merge command in sql 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =