其他分享
首页 > 其他分享> > 查看TOP表

查看TOP表

作者:互联网

set linesize 500
col owner format A20;
col segment_name format A40;
col segment_type format A20;
col tbs format A20;
col size_g format 999999999.9999;

WITH w1 AS
(SELECT ds.owner,
ds.segment_name,
ds.segment_type,
ds.tablespace_name,
ds.bytes
FROM dba_segments ds
WHERE ds.segment_type NOT IN ('LOBSEGMENT')
UNION ALL
SELECT ds.owner,
ds2.segment_name AS segment_name,
ds.segment_type,
ds.tablespace_name,
ds.bytes
FROM dba_segments ds, dba_lobs dl, dba_segments ds2
WHERE ds.owner = dl.owner
AND ds.segment_name = dl.segment_name
AND dl.owner = ds2.owner
AND dl.table_name = ds2.segment_name),
w2 AS
(SELECT w1.owner,
w1.segment_name,
w1.segment_type,
w1.tablespace_name as tbs,
SUM(w1.bytes) / 1024 / 1024 / 1024 AS size_g
FROM w1
GROUP BY w1.owner, w1.segment_name, w1.segment_type, w1.tablespace_name
ORDER BY 5 DESC)
SELECT * FROM w2 WHERE rownum < 11;

标签:name,查看,type,TOP,w1,owner,segment,ds
来源: https://www.cnblogs.com/dbj215/p/15710296.html