Tablespace Empty Checking Jp
テーブルスペースとセグメントの確認
テーブルスペースに格納されているセグメントを確認する必要がよくある。
なければテーブルスペースは空きであると確認もできる。
下記のSQL文で確認できる。
select * from (select tablespace_name from dba_tablespaces ts where tablespace_name like '%PATTERN%') ts full outer join (select segment_name, tablespace_name from user_segments sg where tablespace_name like '%PATTERN%') sg on sg.tablespace_name = ts.tablespace_name
空きのテーブルスペースをリストアップ
下記の文を発行すれば空きのテーブルスペースを確認できる。
select ts.*, sg.tablespace_name from (select tablespace_name from dba_tablespaces ts) ts full outer join (select segment_name, tablespace_name from dba_segments) sg on sg.tablespace_name = ts.tablespace_name where sg.tablespace_name is null and ts.tablespace_name like '%PATTERN%'