剑道第一仙

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

oracle空间及归档查询sql

 

复制代码
-----查看用户表所占用表空间
 select OWNER, t.segment_name, t.segment_type, sum(t.bytes / 1024 / 1024) mmm
 from dba_segments t
 where /*t.owner = '你要查询的用户' */
/*and */t.segment_type='TABLE'
 group by OWNER, t.segment_name, t.segment_type
 order by mmm desc; 

-- 查看归档表空间使用情况
 select trunc(first_time),count(*),round(sum(blocks*block_size)/1024/1024/1024,2) BLOCK5
  from v$archived_log a where a.DEST_ID=1
  group by  trunc(first_time); 
复制代码
复制代码
--查看还原空间使用情况(归档空间不足时查看)
select t.object_name,bytes / 1024 / 1024/1024 as SIZE_M,t.original_name,t.operation,t.createtime,t.droptime 
from dba_recyclebin t
join dba_segments t1 on t.object_name=t1.segment_name
where t.owner='QR_USER' 
order by bytes desc;
;
-- 查看表空间使用情况
select a.tablespace_name,
       a.bytes / 1024 / 1024 "Sum MB",
       (a.bytes - b.bytes) / 1024 / 1024 "used MB",
       b.bytes / 1024 / 1024 "free MB",
       round(((a.bytes - b.bytes) / a.bytes) * 100, 2) "percent_used"
  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;
 
-- 查看segment空间使用情况
 SELECT segment_name, 
tablespace_name, 
r.status, 
(initial_extent / 1024) initialextent, 
(next_extent / 1024) nextextent, 
max_extents, 
v.curext curextent 
FROM dba_rollback_segs r, v$rollstat v 
WHERE r.segment_id = v.usn(+) 
ORDER BY segment_name; 
复制代码

 

posted on   剑道第一仙  阅读(186)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
点击右上角即可分享
微信分享提示