要查看Oracle數據庫中的表空間使用情況,可以使用以下方法:
SELECT tablespace_name,
round(sum(bytes) / 1024 / 1024) total_size_mb,
round(sum(bytes - decode(max(bytes), NULL, 0, max(bytes))) / 1024 / 1024) used_size_mb,
round(decode(max(bytes), NULL, 0, max(bytes)) / 1024 / 1024) largest_free_chunk_mb
FROM dba_free_space
WHERE tablespace_name NOT LIKE 'UNDO%'
GROUP BY tablespace_name;
SELECT file_name,
round(bytes / 1024 / 1024) size_mb,
round((bytes - (blocks * block_size)) / 1024 / 1024) used_size_mb,
round((blocks * block_size) / 1024 / 1024) free_size_mb
FROM dba_data_files;
SELECT name,
round(bytes / 1024 / 1024) total_size_mb,
round(bytes - (bytes * (blocks - empty_blocks)) / blocks / 1024 / 1024) used_size_mb,
round((bytes * (blocks - empty_blocks)) / blocks / 1024 / 1024) free_size_mb
FROM v$tablespace;
以上方法中,可以根據具體需要選擇適合自己的查詢語句進行查看表空間使用情況。