Oracle space and usage

Source: Internet
Author: User

1. Calculation of the table's occupied space

Select S. SEGMENT_NAME, DECODE (SUM (BYTES), NULL, 0, SUM (BYTES)/1024/1024) Mbytes

From DBA_SEGMENTS S

Where S. SEGMENT_NAME = 'mtl _ MATERIAL_TRANSACTIONS '-- table name

And S. SEGMENT_TYPE = 'table'

Group By S. SEGMENT_NAME

2. Calculation of index space used

Select S. SEGMENT_NAME, DECODE (SUM (BYTES), NULL, 0, SUM (BYTES)/1024/1024) Mbytes

From DBA_SEGMENTS S

Where S. SEGMENT_NAME = 'mtl _ MATERIAL_TRANSACTIONS_N1 '-- Index

And S. SEGMENT_TYPE = 'index'

Group By S. SEGMENT_NAME

3. Calculation of the space occupied by partition tables

Select S. SEGMENT_NAME, DECODE (SUM (BYTES), NULL, 0, SUM (BYTES)/1024/1024) Mbytes

From DBA_SEGMENTS S

Where S. SEGMENT_TYPE = 'table partition'

Group By S. SEGMENT_NAME

4. Table space usage

Select a. TABLESPACE_NAME tablespace name,

Round (A. BYTES, 2) "total space (G )",

Round (B. BYTES, 2) "unused space (G )",

ROUND (A. BYTES-B. BYTES)/A. BYTES) * 100, 2) "usage %"

FROM (SELECT TABLESPACE_NAME, SUM (BYTES)/(1024*1024*1024) BYTES

FROM DBA_DATA_FILES

Group by TABLESPACE_NAME),

(SELECT TABLESPACE_NAME, SUM (BYTES)/(1024*1024*1024) BYTES

FROM DBA_FREE_SPACE

Group by TABLESPACE_NAME) B

Where a. TABLESPACE_NAME = B. TABLESPACE_NAME

Order by (A. BYTES-B. BYTES)/A. BYTES) DESC;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.