View the Oracle table space usage and expand the space-poor table file ____oracle

Source: Internet
Author: User

Viewing table space Information

Statement one:

SELECT DBF. Tablespace_name "Table space name",
Dbf. file_name "Table Space file",
Dbf. Totalspace "Total (M)",
Dbf. Totalblocks as total block number,
Dfs. FREESPACE "Total surplus (M)",
Dfs. Freeblocks "Number of remaining blocks",
(DFS. Freespace/dbf. Totalspace) * 100 "free ratio"
From (SELECT T.tablespace_name,
SUM (t.bytes)/1024/1024 Totalspace,
SUM (t.blocks) Totalblocks,
file_name
From Dba_data_files T
GROUP by T.tablespace_name,file_name) DBF,
(SELECT TT. Tablespace_name,
SUM (TT. BYTES)/1024/1024 FREESPACE,
SUM (TT. BLOCKS) freeblocks
From Dba_free_space TT
GROUP by TT. Tablespace_name) DFS
WHERE TRIM (DBF. Tablespace_name) = TRIM (DFS. Tablespace_name)

Statement two:

Select A.tablespace_name "Table space name",
B.file_name as "table space file",
total/1024/1024 | | ' MB ' table space size,
free/1024/1024 | | The remaining size of the ' MB ' table space,
(total-free)/1024/1024 | | The ' MB ' table space uses size,
ROUND ((total-free)/Total, 4) * 100 "Usage%"
From (SELECT tablespace_name, SUM (BYTES) free
From Dba_free_space
GROUP by Tablespace_name) A,
(SELECT tablespace_name, SUM (BYTES) Total, file_name
From Dba_data_files
GROUP by Tablespace_name, file_name) B
WHERE A.tablespace_name = B.tablespace_name
Order by ROUND ((total-free)/Total, 4) * DESC;

To change the size of a table space file:

ALTER DATABASE datafile ' d:/webgisdb/history. ORA ' RESIZE 5000M;

Note: When expanding, be sure to write the path to the file, or you will not be prompted to find the file

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.