首页 > 其他分享 >查看表空间使用率,表,用户大小

查看表空间使用率,表,用户大小

时间:2023-12-18 16:06:55浏览次数:31  
标签:1024 name 查看 bytes 用户 free owner 使用率 round

1.查看表空间使用率

set lin 200 pages 2000
col TABLESPACE_NAME for a32
col free_per for 999.00
col use_per for 999.00
col all_free_per for 999.00

select a.tablespace_name,
               round(a.bytes_alloc / 1024 / 1024, 2) "allocate_size",
               round(nvl(b.bytes_free, 0) / 1024 / 1024, 2) "free_size",
               round((a.bytes_alloc - nvl(b.bytes_free, 0)) / 1024 / 1024, 2) "used_size",
               round((nvl(b.bytes_free, 0) / a.bytes_alloc) * 100, 2) "free_per",
               100 - round((nvl(b.bytes_free, 0) / a.bytes_alloc) * 100, 2) "use_per",
               round(maxbytes /1024/1024, 2) Max,
               round((maxbytes-(a.bytes_alloc - nvl(b.bytes_free, 0)))/ 1024 / 1024,2) "all_free",
               round((1-(a.bytes_alloc - nvl(b.bytes_free, 0))/maxbytes)*100,2)  "all_free_per"
          from (select f.tablespace_name,
                       sum(f.bytes) bytes_alloc,
                       sum(decode(f.autoextensible,
                                  'YES',
                                  f.maxbytes,
                                  'NO',
                                  f.bytes)) maxbytes
                  from dba_data_files f
                 group by tablespace_name) a,
               (select f.tablespace_name, sum(f.bytes) bytes_free
                  from dba_free_space f
                 group by tablespace_name) b
         where a.tablespace_name = b.tablespace_name(+)
union all    ------ under is temp
select h.tablespace_name,
       round(sum(h.bytes_free + h.bytes_used) /1024/1024, 2) "allocate_size",--MB
       round(sum((h.bytes_free + h.bytes_used) - nvl(p.bytes_used, 0)) / 1024/1024, 2) "free_size",
       round(sum(nvl(p.bytes_used, 0))/ 1024/1024, 2) "used_size",
       round((sum((h.bytes_free + h.bytes_used) - nvl(p.bytes_used, 0)) / sum(h.bytes_used + h.bytes_free)) * 100,2) "free_per",
       100 - round((sum((h.bytes_free + h.bytes_used) - nvl(p.bytes_used, 0)) / sum(h.bytes_used + h.bytes_free)) * 100,2) "use_per",
       round(SUM(decode(f.autoextensible, 'YES',f.maxbytes,'NO', f.bytes)) / 1024/1024, 2) max ,--MB
       round(SUM(decode(f.autoextensible, 'YES',f.maxbytes,'NO', f.bytes)) / 1024/1024, 2)-round(sum(nvl(p.bytes_used, 0))/ 1024/1024, 2)"all_free",
       round(( (round(SUM(decode(f.autoextensible, 'YES',f.maxbytes,'NO', f.bytes)) / 1024/1024, 2)-round(sum(nvl(p.bytes_used, 0))/ 1024/1024, 2)) / round(SUM(decode(f.autoextensible, 'YES',f.maxbytes,'NO', f.bytes)) / 1024/1024,2) )*100,2)"all_free_per"
from   sys.v_$TEMP_SPACE_HEADER h, sys.v_$Temp_extent_pool p, dba_temp_files f
where  p.file_id(+) = h.file_id
and    p.tablespace_name(+) = h.tablespace_name
and    f.file_id = h.file_id
and    f.tablespace_name = h.tablespace_name
group by h.tablespace_name
ORDER BY 9;

2.查看表大小

set lin 200 pages 2000
col owner for a25
col TABLE_NAME for a30
col partitioned for a12
col local_index for a12

select t.name instance_name,
       t.owner,
       t.segment_name table_name ,
       t.GB,
       t.partitioned,
       decode(z.locality, 'LOCAL', 'Y', '', 'N') LOCAL_INDEX,
       sysdate
  from (select x.name,
               s.owner,
               s.segment_name,
               s.owner || '.' || s.segment_name table_name,
               sum(bt) GB,
               decode(y.partitioned, 'YES', 'Y', 'NO', 'N') partitioned
          from (select a.owner,
                       case
                         when a.segment_type = 'INDEX' or a.segment_type='INDEX PARTITION' or a.segment_name='LOBINDEX'  then
                          (select b.table_name
                             from dba_indexes b
                            where b.index_name = a.segment_name
                              and b.owner = a.owner)
                         when a.segment_type = 'LOBSEGMENT' or a.segment_type='LOBINDEX' or a.segment_type='LOB PARTITION'  then   
                          (select lb.TABLE_NAME 
                            from dba_lobs lb 
                            where lb.SEGMENT_NAME=a.segment_name  
                            and lb.OWNER=a.owner )     
                         else
                          a.segment_name
                       end segment_name,
                       round(bytes / 1024 / 1024 / 1024, 2) bt
                  from dba_segments a
                ) s,
               v$database x,
               dba_tables y
         where s.segment_name = y.table_name
           and s.owner = y.owner
           and --s.owner='PLT'
             s.owner not in 
('SYS','OGG','SCOTT','SYSTEM', 'OUTLN', 'WMSYS', 'DBSNMP', 'APPQOSSYS', 'EXFSYS','CTXSYS', 'XDB', 'ORDSYS',
'ORDDATA', 'ORDPLUGINS', 'MDSYS','OLAPSYS', 'SYSMAN', 'FLOWS_FILES', 'APEX_030200', 'DMSYS', 'TSMSYS')  
         group by x.name, s.owner, s.segment_name, y.partitioned
        having sum(bt) >= 0.1) t
  left join (select distinct owner || '.' || table_name table_name, locality
               from dba_part_indexes
              where locality = 'LOCAL') z
    on z.table_name = t.table_name
    order by t.GB desc;

3.查看用户大小

set lin 200 pages 2000
col USERNAME for a25
col ACCOUNT_STATUS for a18

select (select name from v$database) instacne_name,
       a.username,
       a.ACCOUNT_STATUS,
       decode(b.sizes, null, 0, b.sizes) sizes
  from dba_users a
  left join (select owner, round(sum(bytes) / 1024 / 1024 / 1024, 2) sizes
               from dba_segments
              group by owner) b
    on a.username = b.owner
 --where a.DEFAULT_TABLESPACE not in ('SYSAUX', 'SYSTEM')
   --and a.ACCOUNT_STATUS = 'OPEN'
 order by sizes desc;


标签:1024,name,查看,bytes,用户,free,owner,使用率,round
From: https://blog.51cto.com/u_15367384/8874570

相关文章

  • GB28181视频监控平台LiteCVR出现用户已过期与401报错,是什么原因?
    安防视频监控新技术的应用使得监控系统变得更加智能化、灵活化,并且提供了更多的便利性和安全性。这些新技术的不断发展也为我们的日常生活和社会安全提供了更大的保障。GB28181视频监控平台LiteCVR可拓展性强、视频能力灵活、部署轻快,可支持的主流标准协议有国标GB28181、RTSP/Onv......
  • c# 获取用户桌面选择的文件
     引用COM组件 Shell32 Shell32.ShellFolderViewdesktopFolderView;inthwnd;Shell32.ShelliShell=newShell32.Shell();SHDocVw.ShellWindowsiWindows=iShell.Windows();SHDocVw.InternetExploreriDesktop=iWindows.FindWindowSW(0,null,8,outhwnd,......
  • etcdctl 查看 etcd 集群状态或者数据脚本
    #!/bin/bash#Author:MichaelLee#Email:[email protected]#Date:07/26/2022#Filename:etcd.sh#定义变量url="https://github.com/etcd-io/etcd/releases/download/v3.4.14/etcd-v3.4.14-linux-amd64.tar.gz"path="/root/etcd"#下载etcd客户端并加入......
  • 查看k8s中etcd数据
    1.查看ETCD集群中运行的ETCDpod[root@master1~]#kubectlgetpod-nkube-system|grepetcdetcd-master11/1Running061metcd-master21/1Running058metcd-master31......
  • mmap内存映射 --- 字符设备驱动,用户空间和内核空间映射到同一个物理内存
    内存映射可实现用户程序对设备驱动内存的直接存取示例代码:驱动层#include<linux/init.h>#include<linux/module.h>#include<linux/miscdevice.h>#include<linux/fs.h>#include<linux/slab.h>//定义kmalloc接口#include<asm/io.h>//定义virt_to_phys接......
  • 关于查看ubuntu下安装的字体
    importmatplotlib.font_managerasfm#获取系统上的所有可用字体font_list=fm.fontManager.ttflist#打印字体列表forfontinfont_list:print(font.name) 这将打印出系统上安装的所有可用字体的名称。如果你只想查看中文字体,可以使用以下代码:importmatplotlib.fo......
  • ABP-VNext 用户权限管理系统实战01---AuthServer服务迁移数据库到mysql
    一、从github上获取源码后修改命名空间下载dome后修改解决方案名为Bridge。 二、默认是连接sqlserver的,需要修改为可以连接mysql修改appsettings.json文件的ConnectionStrings参数,准备一个可以连接的mysql,新建数据库bridge{"ConnectionStrings":{"Default":"Se......
  • linux-用户账号和用户组
    1.1用户标识符:UID,GID虽然我们登陆Linux主机的时候输入的是账号,但其实Linux主机并不会直接认识你的账号名称,账号只是为了方便人。一个文件如何判断他的拥有者ID和拥有组ID呢?其实,就是利用UID和GID。每个文件都会有所谓的GID和UID。当我们需要显示文件实行的需求的时候,系统会根......
  • 用户参数变量和用户定义变量的区别
    一、用户定义变量1:用户定义变量只在启动时获取一次值,在运行过程中不再动态获取变量的值,以下为单线程、单循环的结果  2、继续使用用户定义变量,改为单线程多循环 二、用户参数1、用户参数在启动时会自动获取一次值,在后面运行的过程中也会重新获取一次值设置参数: 使......
  • 全局用户定义变量和局部用户定义变量
    一、线程组内的用户定义变量置1、线程组内的用户变量,属于局部的变量,只能在线程组内适用,下图为线程组中设置了一个用户定义变量  2、然后线程组1使用该变量,线程组1可以注册成功, 3、线程组2使用线程组1的变量,注册失败 二、全局用户自定义变量1、全局用户自定义变量......