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;
,