在线精品99_中国九九盗摄偷拍偷看_91免费版在线观看_91.app_91高清视频在线_99热最新网站

如何通过shell脚本查看数据库表空间使用情况

132次阅读
没有评论

共计 3539 个字符,预计需要花费 9 分钟才能阅读完成。

这篇文章主要介绍如何通过 shell 脚本查看数据库表空间使用情况,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

脚本如下:
sqlplus -s $DB_CONN_STR@$SH_DB_SID   EOF
set echo off heading on underline on;
column inst_num  heading Inst Num  new_value inst_num  format 99999;
column inst_name heading Instance  new_value inst_name format a12;
column db_name   heading DB Name   new_value db_name   format a12;
column dbid      heading DB Id     new_value dbid      format 9999999999 just c;

prompt
prompt Current Instance
prompt ~~~~~~~~~~~~~~~~

select d.dbid            dbid
     , d.name            db_name
     , i.instance_number inst_num
     , i.instance_name   inst_name
  from v\$database d,
       v\$instance i;
       
set term on feedback off lines 130 pagesize 999 tab off trims on
column MB format 999,999,999  heading Total MB
column free format 9,999,999 heading Free MB
column used format 99,999,999 heading Used MB
column Largest format 999,999 heading LrgstMB
column tablespace_name format a20 heading Tablespace
column status format a3 truncated
column max_extents format 99999999999 heading MaxExt
col extent_management           for a1 trunc   head M
col allocation_type             for a1 trunc   head A
col Ext_Size for a4 trunc head Init
column pfree format a3 trunc heading %Fr

break on report
compute sum of MB on report
compute sum of free on report
compute sum of used on report

select  
  d.tablespace_name, 
  decode(d.status, 
    ONLINE , OLN ,
    READ ONLY , R/O ,
    d.status) status,
  d.extent_management, 
  decode(d.allocation_type,
    USER , ,
    d.allocation_type) allocation_type,
  (case 
    when initial_extent 1048576 
    then lpad(round(initial_extent/1024,0),3)|| K  
    else lpad(round(initial_extent/1024/1024,0),3)|| M  
  end) Ext_Size,
  NVL (a.bytes / 1024 / 1024, 0) MB,
  NVL (f.bytes / 1024 / 1024, 0) free, 
  (NVL (a.bytes / 1024 / 1024, 0) – NVL (f.bytes / 1024 / 1024, 0)) used,
  NVL (l.large / 1024 / 1024, 0) largest, 
  d.MAX_EXTENTS ,
  lpad(round((f.bytes/a.bytes)*100,0),3) pfree,
  (case when round(f.bytes/a.bytes*100,0) = 20 then else * end) alrt
FROM sys.dba_tablespaces d,
  (SELECT   tablespace_name, SUM(bytes) bytes
   FROM dba_data_files
   GROUP BY tablespace_name) a,
  (SELECT   tablespace_name, SUM(bytes) bytes
   FROM dba_free_space
   GROUP BY tablespace_name) f,
  (SELECT   tablespace_name, MAX(bytes) large
   FROM dba_free_space
   GROUP BY tablespace_name) l
WHERE d.tablespace_name = a.tablespace_name(+)
  AND d.tablespace_name = f.tablespace_name(+)
  AND d.tablespace_name = l.tablespace_name(+)
  AND NOT (d.extent_management LIKE LOCAL AND d.contents LIKE TEMPORARY)
UNION ALL
select 
  d.tablespace_name, 
  decode(d.status, 
    ONLINE , OLN ,
    READ ONLY , R/O ,
    d.status) status,
  d.extent_management, 
  decode(d.allocation_type,
    UNIFORM , U ,
    SYSTEM , A ,
    USER , ,
    d.allocation_type) allocation_type,
  (case 
    when initial_extent 1048576 
    then lpad(round(initial_extent/1024,0),3)|| K  
    else lpad(round(initial_extent/1024/1024,0),3)|| M  
  end) Ext_Size,
  NVL (a.bytes / 1024 / 1024, 0) MB,
  (NVL (a.bytes / 1024 / 1024, 0) – NVL (t.bytes / 1024 / 1024, 0)) free,
  NVL (t.bytes / 1024 / 1024, 0) used, 
  NVL (l.large / 1024 / 1024, 0) largest, 
  d.MAX_EXTENTS ,
  lpad(round(nvl(((a.bytes-t.bytes)/NVL(a.bytes,0))*100,100),0),3) pfree,
  (case when nvl(round(((a.bytes-t.bytes)/NVL(a.bytes,0))*100,0),100) = 20 then else * end) alrt
FROM sys.dba_tablespaces d,
  (SELECT   tablespace_name, SUM(bytes) bytes
   FROM dba_temp_files
   GROUP BY tablespace_name order by tablespace_name) a,
  (SELECT   tablespace_name, SUM(bytes_used  ) bytes
   FROM v\$temp_extent_pool
   GROUP BY tablespace_name) t,
  (SELECT   tablespace_name, MAX(bytes_cached) large
   FROM v\$temp_extent_pool
   GROUP BY tablespace_name order by tablespace_name) l
WHERE d.tablespace_name = a.tablespace_name(+)
  AND d.tablespace_name = t.tablespace_name(+)
  AND d.tablespace_name = l.tablespace_name(+)
  AND d.extent_management LIKE LOCAL
  AND d.contents LIKE TEMPORARY
  ORDER by 1
/
prompt
exit
EOF

运行结果相对比较简单,也很清晰。

以上是“如何通过 shell 脚本查看数据库表空间使用情况”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注丸趣 TV 行业资讯频道!

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-07-24发表,共计3539字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)
主站蜘蛛池模板: 亚洲欧洲日产国码无码久久99 | 欧美大陆日韩一区二区三区 | jizzjizz18日本护士 | 国产激情小视频 | 91精品一区二区三区在线观看 | 国产成人精品免费视频大全五级 | 极品丝袜高跟91白沙发在线 | 日韩中文字幕视频在线 | 日韩熟女精品一区二区三区 | 99在线精品日韩一区免费国产 | 青青青青青青在线精品视频 | 白嫩美女直冒白浆 | 亚洲av成人无码精品电影在线 | 亚洲av日韩av一区二区三曲 | 亚洲精品国偷拍自产在线观看蜜臀 | 二区国产| 色94色欧美sute亚洲线路一 | 亚洲天堂视频网站 | 精品久久久在线观看 | 福利视频一二三在线视频免费观看 | 日韩欧美一区二区久久 | 久久久免费视频播放 | 亚洲欧洲日本精品 | 亚洲欧美久久精品一区 | 四虎精品在线视频 | 亚洲综合在线播放 | 人妻互换一二三区激情视频 | 国产精品久久免费 | 成在线人免费视频 | 日韩福利| 在线涩涩免费观看国产精品 | 免费网站成人亚洲 | 精品国产粉嫩内射白浆内射双马尾 | 亚洲精品色午夜无码专区日韩 | 欧美精品成人 | 欧美日本一区二区 | a级黄色毛片 | 91成人免费视频 | 国产av无码专区亚洲精品 | 男女做爰猛烈吃奶啪啪喷水网站 | 四虎精品免费永久免费视频 |