Query the actual physical usage of an Oracle table

Source: Internet
Author: User

Two meanings of table size in Oracle
One is the number of physical spaces allocated to a table, regardless of whether the space is used or not. You can query the number of bytes as follows:
Select segment_name, bytes
From user_segments
Where segment_type = TABLE;
The effect is as follows:


Or
Select Segment_Name, Sum (bytes)/1024/1024 from User_Extents Group By Segment_Name;
The result is as follows: [this query is slow]
 

As shown in the results of the above two figures, the query is the size allocated to the table by 10896M.
Query the actual space occupied by the table.

Space actually used by another table. Query as follows:
Analyze table emp compute statistics;
Select num_rows * avg_row_len
From user_tables
Where table_name = EMP; -- EMP is the table name (table name Big write query)
The effect is as follows:
 

The actual space occupied by the table is about 9506M.
 
 
Appendix:
View the size of each tablespace
Select Tablespace_Name, Sum (bytes)/1024/1024 from Dba_Segments Group By Tablespace_Name
1. view the remaining tablespace size
 
SELECT tablespace_name tablespace, sum (blocks * 8192/1000000) residual space M from dba_free_space group by tablespace_name;
 
2. Check the total space of all tablespaces in the system.
Select B. name, sum (. bytes/1000000) total space from v $ datafile a, v $ tablespace B where. ts # = B. ts # group by B. name;
 
3. query the remaining and used table space usage of the entire database:
Select df. tablespace_name "tablespace name", totalspace "total space M", freespace "remaining space M", round (1-freespace/totalspace) *, 2) "usage %"
From
(Select tablespace_name, round (sum (bytes)/1024/1024) totalspace
From dba_data_files
Group by tablespace_name) df,
(Select tablespace_name, round (sum (bytes)/1024/1024) freespace
From dba_free_space
Group by tablespace_name) fs
Where df. tablespace_name = fs. tablespace_name;
The effect is as follows:
 

Related Article

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.