可以使用以下SQL語句來查看表空間的大小及使用情況:
SELECT tablespace_name,
ROUND(SUM(bytes) / 1024 / 1024, 2) AS total_space_mb,
ROUND(SUM(bytes - decode(maxbytes, 0, bytes, maxbytes)) / 1024 / 1024, 2) AS used_space_mb,
ROUND(SUM(decode(maxbytes, 0, bytes, maxbytes) - bytes) / 1024 / 1024, 2) AS free_space_mb
FROM dba_data_files
GROUP BY tablespace_name;
SELECT file_name,
tablespace_name,
ROUND(bytes / 1024 / 1024, 2) AS file_size_mb,
ROUND(bytes - decode(maxbytes, 0, bytes, maxbytes) / 1024 / 1024, 2) AS used_space_mb,
decode(maxbytes, 0, bytes, maxbytes) / 1024 / 1024 AS max_space_mb,
autoextensible,
status
FROM dba_data_files;
SELECT tablespace_name,
file_name,
ROUND(bytes / 1024 / 1024, 2) AS file_size_mb,
ROUND(maxbytes / 1024 / 1024, 2) AS max_size_mb,
ROUND(bytes - decode(maxbytes, 0, bytes, maxbytes) / 1024 / 1024, 2) AS used_space_mb,
decode(maxbytes, 0, bytes, maxbytes) / 1024 / 1024 AS max_space_mb,
autoextensible,
status
FROM dba_data_files;