0% found this document useful (0 votes)
108 views2 pages

Temp Tablespace Usage

This document provides SQL queries to view TEMP tablespace usage. The first query displays which sessions are using the TEMP tablespace and how much space each is using. The second query sums the used and free bytes in the TEMP tablespace. The third query checks the free space within the used portion of the TEMPFILE by joining views to get the tablespace name, total megabytes, used megabytes, and free megabytes.

Uploaded by

mdrajiv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
108 views2 pages

Temp Tablespace Usage

This document provides SQL queries to view TEMP tablespace usage. The first query displays which sessions are using the TEMP tablespace and how much space each is using. The second query sums the used and free bytes in the TEMP tablespace. The third query checks the free space within the used portion of the TEMPFILE by joining views to get the tablespace name, total megabytes, used megabytes, and free megabytes.

Uploaded by

mdrajiv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

SQL : temp tablespace usage

/*
The query below will display which sessions are using TEMP tablespace and how mu
ch space is
being used by each session:
*/
set pages 100
set lines 300
col tablespace for a20
col username for a15
col osuser for a10
SELECT b.TABLESPACE
, b.segfile#
, b.segblk#
, ROUND ( ( ( b.blocks * p.VALUE ) / 1024 / 1024 ), 2 ) size_mb
, a.SID
, a.serial#
, a.username
, a.osuser
, a.program
, a.status
FROM v$session a
, v$sort_usage b
, v$process c
, v$parameter p
WHERE p.NAME = 'db_block_size'
AND a.saddr = b.session_addr
AND a.paddr = c.addr
ORDER BY b.TABLESPACE, b.segfile#, b.segblk#, b.blocks;
/*
To see how much space is being used and free in TEMP tablespace run the followin
g sql:
*/
SELECT tablespace_name, SUM(bytes_used), SUM(bytes_free)
FROM v$temp_space_header
GROUP BY tablespace_name;
/*
Run the following statement to check the free space within the used portion of T
EMPFILE (if
you are running older version of Oracle and don't have tempfile you can replace
v$tempfile
with v$datafile):
*/
SELECT
FROM

A.tablespace_name tablespace, D.mb_total,


SUM (A.used_blocks * D.block_size) / 1024 / 1024 mb_used,
D.mb_total - SUM (A.used_blocks * D.block_size) / 1024 / 1024 mb_free
v$sort_segment A,
(
SELECT B.name, C.block_size, SUM (C.bytes) / 1024 / 1024 mb_total
FROM
v$tablespace B, v$tempfile C
WHERE
B.ts#= C.ts#
GROUP BY B.name, C.block_size

) D
WHERE
A.tablespace_name = D.name
GROUP by A.tablespace_name, D.mb_total;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy