要查詢Oracle數據庫中表空間的信息,可以使用以下查詢:
SELECT tablespace_name, file_name, bytes/1024/1024 AS "Size (MB)",
bytes/1024/1024 - (sum(nvl(bytes,0))/1024/1024) as "Used (MB)",
(sum(nvl(bytes,0))/1024/1024) as "Free (MB)",
round(sum(nvl(bytes,0))*100/sum(sum(nvl(bytes,0))) over(),2) as "Used %"
FROM dba_data_files
GROUP BY tablespace_name, file_name, bytes
ORDER BY tablespace_name;
這條查詢語句將顯示每個表空間的名稱,文件名,大小(以MB為單位),已使用空間(以MB為單位),剩余空間(以MB為單位)和已使用的百分比。