1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Oracle】表ごとのセグメントサイズ合計(表、LOB、索引)を出力する【SQL*Plus】

Posted at

dba_segmentssegment_nameでしか表名・LOB名など指定できないため、表ごと・LOBごとでサイズを見ることになります。
仕様上、「1つの表にかかわる全体のセグメントサイズ」を見積もりたいときちょっと面倒なので、スクリプト作りました。
union allでくっつけてsumするゴリ押しです。

不要ならdba_indexes削除。
group byの前か各select文にwhere OWNER(TABLE_NAME) = '~~~'指定。

--table,index,lob

select OWNER,TABLE_NAME,sum(M_BYTES) from (
select t.OWNER,t.TABLE_NAME,s.BYTES/1024/1024 M_BYTES
from dba_tables t
inner join dba_segments s on
s.SEGMENT_TYPE in ('TABLE','TABLE PARTITION') and
t.OWNER = s.OWNER and
t.TABLE_NAME = s.SEGMENT_NAME
union all
select i.OWNER,i.TABLE_NAME,s.BYTES/1024/1024 M_BYTES
from dba_indexes i
inner join dba_segments s on
s.SEGMENT_TYPE in ('INDEX','LOBINDEX','INDEX PARTITION') and
i.OWNER = s.OWNER and
i.INDEX_NAME = s.SEGMENT_NAME
union all
select l.OWNER,l.TABLE_NAME,s.BYTES/1024/1024 M_BYTES
from dba_lobs l
inner join dba_segments s on
s.SEGMENT_TYPE in ('LOBSEGMENT','LOB PARTITION') and
l.OWNER = s.OWNER and
l.SEGMENT_NAME = s.SEGMENT_NAME)
group by OWNER,TABLE_NAME
order by 1,2,3;
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?