ORACLE用户表空间使用情况查询

时间:2024-01-10 11:28:32

1.查询用户使用的表空间:

 select username,default_tablespace,temporary_tablespace
from dba_users
where username = '用户名称';

2.查询表空间使用情况:

 SELECT a.tablespace_name TABLESPACE_NAME,
total / 1048576 TOTAL_M,
free / 1048576 FREE_M,
(total - free) / 1048576 USED_M,
ROUND((total - free) / total, 4) * 100 "USED%",
autoextensible autoextem
FROM (SELECT tablespace_name, SUM(bytes) free
FROM DBA_FREE_SPACE
GROUP BY tablespace_name) a,
(SELECT tablespace_name,
SUM(bytes) total,
max(autoextensible) autoextensible
FROM DBA_DATA_FILES
GROUP BY tablespace_name) b
WHERE a.tablespace_name = b.tablespace_name
order by 6, 5 desc

3.查看表空间对应的数据文件

 select tablespace_name, file_id, file_name,
round(bytes/(1024*1024),0) total_space
from dba_data_files
order by tablespace_name;

2018-08-1613:25:52