Home > Database > Mysql Tutorial > body text

onesqltocalculatetheschema'stablecapacity

WBOY
Release: 2016-06-07 15:55:18
Original
1137 people have browsed it

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 ;
Copy after login

Related labels:
amp
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!