How can Oracle query the storage space in the database?

To inquire about the storage space of a database, you can use the following SQL query statement:

SELECT tablespace_name, 
       SUM(bytes) / 1024 / 1024 AS "Total Size(MB)", 
       SUM(bytes - blocks * 8192) / 1024 / 1024 AS "Used Size(MB)", 
       SUM(blocks * 8192) / 1024 / 1024 AS "Free Size(MB)"
FROM dba_data_files
GROUP BY tablespace_name;

This SQL query will provide the total size, used size, and remaining space size for each tablespace. You can modify the query conditions as needed to meet your requirements.

广告
Closing in 10 seconds
bannerAds