Oracle view the use of each physical file in the Tablespace ____oracle

Source: Internet
Author: User
--View the use of table space files


SELECT
MAX (b.file_id) ID,
B.tablespace_name table Space,
B.file_name Physical file name,
b.bytes/1024/1024 size M,
(B.bytes-sum (NVL (a.bytes, 0)))/1024/1024 has used M,
SUBSTR (B.bytes-sum (NVL (a.bytes, 0))/(b.bytes) * 100, 1, 5) utilization
From Dba_free_space A, Dba_data_files B
WHERE a.file_id = b.file_id
GROUP by B.tablespace_name, B.file_name, b.bytes

Order BY B.tablespace_name;



--Automatically generate a statement to reduce the size of the table space




Select ' ALTER DATABASE datafile ' ' | | A.file_name | | "' Resize ' | |
Round (A.filesize-(a.filesize-c.hwmsize-100) * 0.8) | | ' M; ',
A.filesize | | Total size of ' M ' as ' data file ',
C.hwmsize | | Practical size of ' M ' as data file
From (select file_id, file_name, round (bytes/1024/1024) as FileSize
From Dba_data_files) A,
(select file_id, round (max (block_id) * 8/1024) as Hwmsize
From Dba_extents
Group by FILE_ID) c
where a.file_id = c.file_id
and a.filesize-c.hwmsize > 100;



--performing a reduced table space file


ALTER DATABASE datafile ' C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS02. DBF ' RESIZE 300M



--View table space files


Select File#,name from V$datafile


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.