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

How To Calculate Space Used by LOB Segments in The Database (Doc ID 369883.1)

Uploaded by

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

How To Calculate Space Used by LOB Segments in The Database (Doc ID 369883.1)

Uploaded by

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

Copyright (c) 2023, Oracle. All rights reserved. Oracle Confidential.

How to Calculate Space Used by LOB Segments in the Database (Doc ID 369883.1)

In this Document

Goal
Solution
References

APPLIES TO:

Oracle Database Exadata Express Cloud Service - Version N/A and later
Oracle Database Cloud Exadata Service - Version N/A and later
Oracle Database Cloud Schema Service - Version N/A and later
Oracle Database Backup Service - Version N/A and later
Oracle Database Cloud Service - Version N/A and later
Information in this document applies to any platform.

GOAL

NOTE: In the images and/or the document content below, the user information and environment data used represents
fictitious data from the Oracle sample or bulit-in schema(s), Public Documentation delivered with an Oracle database
product or other training material. Any similarity to actual environments, actual persons, living or dead, is purely
coincidental and not intended in any manner.

This Note provides sql queries to find Space Used by LOB Segments in the Database using views USER_LOBS or
ALL_LOBS. We also need access on DBA_SEGMENTS to find the matching LOB segment.

SOLUTION

This SQL will list all LOB segments by schema using the USER_LOBS view. For schema (scott in example) to be able to
select form dba_segments, will need to granted select on the view. ( i.e. grant select on sys.dba_segments to scott; )

SQL> connect scott/<password>


Connected.
SQL> col segment_name format a30
SQL> set pagesize 10000
SQL> select a.segment_name, a.segment_type,
2 sum(a.bytes)/1024/1024 Bytes_MB
3 from dba_segments a, user_lobs b
4 where a.segment_name = b.segment_name
5 group by a.segment_name, a.segment_type;

SEGMENT_NAME SEGMENT_TYPE BYTES_MB


------------------------------ ------------ ----------
LOBSEGMENT LOBSEGMENT .0625
SYS_LOB0000051218C00001$$ LOBSEGMENT .0625

To extract the tablespace name, table name, LOB column name, here would be the SQL to accomplish.
SQL> connect scott/<password>
Connected.
SQL> set pagesize 10000
SQL> col tablespace_name format a10
SQL> col TS_Name format a10
SQL> col Col format a10
SQL> col segment_type format a12
SQL> select a.tablespace_name TS_Name, b.table_name,
2 b.column_name Col, a.segment_type,
3 sum(a.bytes)/1024/1024 Bytes_MB
4 from dba_segments a, user_lobs b
5 where a.segment_name = b.segment_name
6 group by a.tablespace_name, b.table_name,
7 b.column_name, a.segment_type;

TS_NAME TABLE_NAME COL SEGMENT_TYPE BYTES_MB


---------- ---------- ---------- ------------ ----------
USERS TESTLOB TESTLOBC LOBSEGMENT .0625
USERS TESTLOB2 TESTLOBB LOBSEGMENT .0625

Then here is similar SQL that will list all LOB segments on the DB using the ALL_LOBS view.

col segment_name format a30


set pagesize 10000
select a.owner, a.segment_name, a.segment_type,
sum(a.bytes)/1024/1024 Bytes_MB
from dba_segments a, all_lobs b
where a.segment_name = b.segment_name
group by a.owner, a.segment_name, a.segment_type;

The SQL should provide a foundation that can be modified as needed to find and report the LOBs space utilization as
needed.

REFERENCES
NOTE:253131.1 - Concurrent Writes May Corrupt LOB Segment When Using Auto Segment Space Management (ORA-
1555)
NOTE:159995.1 - Different Behaviors of Lob and Lobindex Segments in 8.0, 8i and 9i
NOTE:161994.1 - How to Check Whether a BLOB Type Column is Empty or Not
NOTE:198160.1 - Summary Note Index for BasicFiles(LOB's/BLOB's/CLOB's/NCLOB's/BFILES) and SecureFiles
Didn't find what you are looking for?

You might also like