首页 > 数据库 > mysql教程 > onesqltocalculatetheschema'stablecapacity

onesqltocalculatetheschema'stablecapacity

WBOY
发布: 2016-06-07 15:55:18
原创
1194 人浏览过

SELECT owner, table_name, TRUNC(SUM(bytes)/(1024*1024)) MBFROM (SELECT segment_name table_name, owner, bytes FROM dba_segments WHERE segment_type = 'TABLE' UNION ALL SELECT i.table_name, i.owner, s.bytes FROM dba_indexes i, dba_segments s

SELECT owner,
  table_name,
  TRUNC(SUM(bytes)/(1024*1024)) MB
FROM
  (SELECT segment_name table_name,
    owner,
    bytes
  FROM dba_segments
  WHERE segment_type = 'TABLE'
  UNION ALL
  SELECT i.table_name,
    i.owner,
    s.bytes
  FROM dba_indexes i,
    dba_segments s
  WHERE s.segment_name = i.index_name
  AND s.owner          = i.owner
  AND s.segment_type   = 'INDEX'
  UNION ALL
  SELECT l.table_name,
    l.owner,
    s.bytes
  FROM dba_lobs l,
    dba_segments s
  WHERE s.segment_name = l.segment_name
  AND s.owner          = l.owner
  AND s.segment_type   = 'LOBSEGMENT'
  UNION ALL
  SELECT l.table_name,
    l.owner,
    s.bytes
  FROM dba_lobs l,
    dba_segments s
  WHERE s.segment_name = l.index_name
  AND s.owner          = l.owner
  AND s.segment_type   = 'LOBINDEX'
  )
GROUP BY table_name,
  owner
ORDER BY SUM(bytes) DESC ;
登录后复制

相关标签:
amp
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板