签到成功

知道了

CNDBA社区CNDBA社区

oracle DBA常用的SQL

2016-12-05 14:52 2074 0 原创
作者: Anshen



-1、查看表空间的名称及大小 

SELECT t.tablespace_name, round(SUM(bytes / (1024 * 1024)), 0) ts_size 

FROM dba_tablespaces t, dba_data_files d http://www.cndba.cn/redhat/article/1608

WHERE t.tablespace_name = d.tablespace_name 

GROUP BY t.tablespace_name; 

http://www.cndba.cn/redhat/article/1608

--2、查看表空间物理文件的名称及大小 

SELECT tablespace_name, 

file_id, 

file_name, 

round(bytes / (1024 * 1024), 0) total_space 

FROM dba_data_files 

ORDER BY tablespace_name; 

--3、查看回滚段名称及大小 

SELECT segment_name, 

tablespace_name, 

r.status, 

(initial_extent / 1024) initialextent, 

(next_extent / 1024) nextextent, http://www.cndba.cn/redhat/article/1608

max_extents, 

v.curext curextent 

FROM dba_rollback_segs r, v$rollstat v 

WHERE r.segment_id = v.usn(+) 

ORDER BY segment_name; 

--4、查看控制文件 

SELECT NAME FROM v$controlfile; http://www.cndba.cn/redhat/article/1608

--5、查看日志文件 

http://www.cndba.cn/redhat/article/1608

SELECT MEMBER FROM v$logfile; 

--6、查看表空间的使用情况 

SELECT SUM(bytes) / (1024 * 1024) AS free_space, tablespace_name 

FROM dba_free_space 

GROUP BY tablespace_name; 

SELECT a.tablespace_name, http://www.cndba.cn/redhat/article/1608

a.bytes total, 

b.bytes used, http://www.cndba.cn/redhat/article/1608

c.bytes free, 

(b.bytes * 100) / a.bytes "% USED ", 

(c.bytes * 100) / a.bytes "% FREE " 

FROM sys.sm$ts_avail a, sys.sm$ts_used b, sys.sm$ts_free c 

WHERE a.tablespace_name = b.tablespace_name 

AND a.tablespace_name = c.tablespace_name; 

--7、查看数据库库对象 

SELECT owner, object_type, status, COUNT(*) count# 

FROM all_objects 

GROUP BY owner, object_type, status; 

--8、查看数据库的版本  

SELECT version 

FROM product_component_version 

WHERE substr(product, 1, 6) = 'Oracle'; http://www.cndba.cn/redhat/article/1608

--9、查看数据库的创建日期和归档方式 

SELECT created, log_mode, log_mode FROM v$database; 



http://www.cndba.cn/redhat/article/1608




http://www.cndba.cn/redhat/article/1608



版权声明:本文为博主原创文章,未经博主允许不得转载。

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
Anshen

Anshen

关注

成功不是将来才有的,而是从决定去做的那一刻起,持续累积而成。

  • 69
    原创
  • 0
    翻译
  • 5
    转载
  • 8
    评论
  • 访问:290854次
  • 积分:326
  • 等级:中级会员
  • 排名:第13名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ