(1)查询用户对应的表空间,我们可以看到针对不同的数据库用户Oracle
select username, default_tablespace, temporary_tablespace from dba_users;
(2)查询用户的对应的数据文件,以及数据文件大小
selecttablespace_name, file_id, file_name,round(bytes/(1024*1024),0) total_space from dba_data_files
order bytablespace_name;
SELECT a.tablespace_name "表空间名",total "表空间大小",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 ;