--首先查询用户默认空间
select username,default_tablespace from user_users;
--然后
SELECT a.tablespace_name as 表空间名,
total as 表空间大小,
free 表空间剩余大小,
(total - free) 表空间使用大小,
total / (1024 * 1024 * 1024) 表空间大小G,
free / (1024 * 1024 * 1024) 表空间剩余大小G,
(total - free) / (1024 * 1024 * 1024) 表空间使用大小G,
round((total - free) / total, 4) * 100 使用率百分比
FROM (SELECT tablespace_name, SUM(bytes) free
FROM dba_free_space
GROUP BY tablespace_name) a,
(SELECT tablespace_name, SUM(bytes) total
FROM dba_data_files
GROUP BY tablespace_name) b
WHERE a.tablespace_name = b.tablespace_name
and a.tablespace_name = 'AUDIT_FLEX' --命名空间
order by a.tablespace_name;