Search
 
SCRIPT & CODE EXAMPLE
 

SQL

oracle undo usage by session

-- UNDO tablespace current usage / available space
SELECT a.TABLESPACE_NAME, SIZEMB, USAGEMB, (SIZEMB - USAGEMB) AS FREEMB
FROM (SELECT round(sum(BYTES) / 1e6) AS SIZEMB, b.TABLESPACE_NAME
      FROM DBA_DATA_FILES a, DBA_TABLESPACES b
      WHERE a.TABLESPACE_NAME = b.TABLESPACE_NAME AND b.CONTENTS LIKE '%UNDO%'
      GROUP BY b.TABLESPACE_NAME) a,
     (SELECT c.TABLESPACE_NAME, sum(BYTES) / 1e6 AS USAGEMB
      FROM DBA_UNDO_EXTENTS c
      WHERE STATUS <> 'EXPIRED'
      GROUP BY c.TABLESPACE_NAME) b
WHERE a.TABLESPACE_NAME = b.TABLESPACE_NAME;
Comment

oracle undo usage by session

-- UNDO tablespace usage per user / session
SELECT s.SID, s.USERNAME, round(sum(ss.VALUE) / 1e6, 2) AS UNDO_SIZE_MB,
       sql.ELAPSED_TIME, sql.SQL_TEXT
FROM V$SESSTAT ss JOIN V$SESSION s ON s.SID = ss.SID
     JOIN V$STATNAME STAT ON STAT.STATISTIC# = ss.STATISTIC#
     LEFT JOIN V$SQLAREA sql 
     	ON s.SQL_ADDRESS = sql.ADDRESS AND s.SQL_HASH_VALUE = sql.HASH_VALUE
WHERE STAT.NAME = 'undo change vector size' AND s.TYPE <> 'BACKGROUND' 
  AND s.USERNAME IS NOT NULL AND ss.VALUE >= 0.01 * 1e6
GROUP BY s.SID, s.USERNAME, sql.ELAPSED_TIME, sql.SQL_TEXT
ORDER BY s.USERNAME, round(sum(ss.VALUE) / 1e6, 2);
Comment

oracle undo usage per session

-- UNDOTBS usage per User:
SELECT u.TABLESPACE_NAME          AS TABLESPACE,
       s.USERNAME,
       u.STATUS,
       sum(u.BYTES) / 1024 / 1024 AS SUM_IN_MB,
       count(u.SEGMENT_NAME)      AS SEG_CNTS
FROM DBA_UNDO_EXTENTS u, V$TRANSACTION T, V$SESSION s
WHERE T.ADDR = s.TADDR
GROUP BY u.TABLESPACE_NAME, s.USERNAME, u.STATUS
ORDER BY 1, 2, 3;
Comment

PREVIOUS NEXT
Code Example
Sql :: sql delete join 
Sql :: how to search date in sql query 
Sql :: how to drop a database in sql server when it is in use 
Sql :: python sqlite3 prepared statement 
Sql :: mysql order by desc null last 
Sql :: t sql get foreign key 
Sql :: SQL: merging multiple row data in string 
Sql :: select latest entry in sql table 
Sql :: sql query to search for a string in all columns 
Sql :: mysql remove duplicates 
Sql :: mssql find deadlocks 
Sql :: mysql create database with collation 
Sql :: current year sql 
Sql :: sql calculate percentage 
Sql :: date format in sql 
Sql :: how to fetch first 5 characters in sql 
Sql :: random name function in mysql for nvarchar 
Sql :: sql convert xml to text 
Sql :: mysql change auto_increment start value 
Sql :: sql limit results returned 
Sql :: reseed sql table primary key 
Sql :: SQL COUNT() with DISTINCT 
Sql :: mysql database create 
Sql :: sql upsert 
Sql :: postgres create extension if not exists 
Sql :: oracle create table if not exists 
Sql :: sql select into 
Sql :: mysql export and import 
Sql :: mysql dump specific tables 
Sql :: sql convert date to string yyyy-mm-dd 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =