--查询表空间大小
select a.tablespace_name,
a.bytes / 1024 / 1024 "总空间/MB",
(a.bytes - b.bytes) / 1024 / 1024 "已用空间/MB",
b.bytes / 1024 / 1024 "剩余空间/MB",
round(((a.bytes - b.bytes) / a.bytes) * 100, 2) "使用率/%"
from (select tablespace_name, sum(bytes) bytes
from dba_data_files
group by tablespace_name) a,
(select tablespace_name, sum(bytes) bytes, max(bytes) largest
from dba_free_space
group by tablespace_name) b
where a.tablespace_name = b.tablespace_name
order by ((a.bytes - b.bytes) / a.bytes) desc;
--查询用户名,表空间
select username, default_tablespace from dba_users;
--查看所有用户
select * from all_users where username like '%ecms%';
--查看当前用户的缺省表空间
select username,default_tablespace from user_users;
--查询表空间下所有用户的表名
select * from dba_tables where tablespace_name like 'EPMSDEV';
--查看当前用户下的表占用空间大小
Select Segment_Name 表名, Sum(bytes) / 1024 / 1024 "已占用/MB"
From User_Extents
where Segment_Name like '%B_SYS%'
Group By Segment_Name
order by Sum(bytes);