oracle数据库查询表空间
时间: 2023-11-27 15:03:37 浏览: 93
要查询Oracle数据库的表空间,你可以使用以下SQL语句:
1. 查询数据文件信息:
select * from dba_data_files;
2. 查询临时数据文件信息:
select * from dba_temp_files;
3. 查询数据库中所有表空间中的空闲扩展区:
select * from dba_free_space;
4. 查询数据库中的所有段分配的存储:
select * from dba_segments;
5. 查询表空间的空闲扩展区:
select tablespace_name, count(*) AS extends, round(sum(bytes) / 1024 / 1024, 2) AS 大小/MB , sum(blocks) AS blocks from dba_free_space group BY tablespace_name;
6. 查询表空间的总容量:
select tablespace_name, sum(bytes) / 1024 / 1024 as MB from dba_data_files group by tablespace_name;
7. 查询表空间使用率:
SELECT total.tablespace_name, Round(total.MB, 2) AS 总量/MB, Round(total.MB - free.MB, 2) AS 已使用/MB, Round(( 1 - free.MB / total.MB ) * 100, 2) || '%' AS 使用率 FROM (SELECT tablespace_name, Sum(bytes) / 1024 / 1024 AS MB FROM dba_free_space GROUP BY tablespace_name) free, (SELECT tablespace_name, Sum(bytes) / 1024 / 1024 AS MB FROM dba_data_files GROUP BY tablespace_name) total WHERE free.tablespace_name = total.tablespace_name;
阅读全文