Oracle disk space usage statistics

Source: Internet
Author: User
For large databases, Oracle occupies a very large disk space. It can grasp the disk space occupied by users and tables in the database, and increase the disk space.

For large databases, Oracle occupies a very large disk space. It can grasp the disk space occupied by users and tables in the database, and increase the disk space.

For large databases, Oracle occupies a very large disk space, master the database users and tables that occupy a lot of disk space to kill, and increase the situation, you can easily maintain and expand the disk system in the future.

The usage of Oracle disk space can be divided into tablespaces, users, or tables for statistics.

(1) tablespace

Calculate the remaining tablespace size

Select A. TABLESPACE_NAME, A. BYTES/(1024*1024*1024) "SPACE (G )",
C. BYTES/(1024*1024) "free space (M)", (C. BYTES * 100)/A. BYTES "% FREE"
From sys. SM $ TS_AVAIL A, SYS. SM $ TS_FREE C
Where a. TABLESPACE_NAME = C. TABLESPACE_NAME;
Or

Select tablespace_name, sum (bytes)/(1024*1024*1024) "SPACE (G )"
From dba_free_space
Group by tablespace_name;
(2) Users

Calculate the disk space occupied by each user

Select owner, sum (bytes)/1024/1024/1024 "Space (G )"
From dba_segments
Group by owner
Order by 2;
Calculates the disk space occupied by a user.

Select owner, sum (bytes)/1024/1024/1024 "Space (G )"
From dba_segments
Where owner = 'liaojl'
Group by owner;
(3) tables

Oracle uses segments for storage. segment_name contains tables, indexes, and rollback segments. Therefore, dba_extents and dba_segments can all find space-consuming information.

Select sum (bytes)/1024/1024 "Space (M )"
From dba_extents
Where owner = 'liaojl 'and segment_name = 'students ';
Dba_segments can also calculate the table size:

Select segment_name, bytes/1024/1024 "Space (MB )"
From dba_segments
Where SEGMENT_TYPE = 'table' and segment_name = upper ('name of the TABLE you are looking ');
At that time, the preceding statement was not completely correct. When the table is a partition table, dba_segments has multiple pieces of information, which can be changed:

Select segment_name, sum (bytes)/1024/1024 "Space (MB )"
From dba_segments
Where segment_name = upper ('name of the table you are looking ');
The preceding method is slow to execute SQL statements for a large database and consumes database resources. Oracle supports table analysis. After performing the analysis table operation, you can query the table size, number of rows, and other information in system tables such as dba_tables. However, this information is not updated in real time and can be used when the database is idle, update by planning tasks.

SQL analysis method:

Analyze table tab_name compute statistics;
If the table is too large, run:

Analyze table tab_name estimate statistics;

,

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.