12月 172020
 

テーブルが何バイト使っているか調べる

DBA権限が必要。

SELECT*FROM(SELECTowner,tablespace_name,segment_name,SUM(bytes) / (1024 * 1024 * 1024) GBFROMdba_segmentsGROUP BYowner,tablespace_name,segment_name)ORDER BYGB DESC

ログインユーザの持ち物に限るのであれば

SELECT*FROM(SELECTtablespace_name,segment_name,SUM(bytes) / (1024 * 1024 * 1024) GBFROMuser_segmentsGROUP BYtablespace_name,segment_name)ORDER BYGB DESC

表領域の残り空き容量を調べる

SELECTspace.tablespace_name,TRUNC(space.bytes      / (1024*1024*1024)*100)/100 "Capacity GB",TRUNC(free_space.bytes / (1024*1024*1024)*10000)/10000 "Free GB",TRUNC(free_space.bytes /space.bytes*100*10000)/10000 "Free Percentage"FROM(SELECTtablespace_name,SUM(bytes) bytesFROMdba_free_spaceGROUP BYtablespace_name)free_spaceLEFT JOIN(SELECTtablespace_name,SUM(bytes) bytesFROMdba_data_filesGROUP BYtablespace_name)spaceONfree_space.tablespace_name = space.tablespace_nameORDER BYspace.tablespace_name

スキーマが何バイト使っているか調べる

select*from(SELECTowner,SUM(bytes)/ (1024*1024*1024) "GB"FROMdba_segmentsGROUP BYowner)order by "GB" desc

スキーマが表領域単位で何バイト使っているか調べる

select*from(SELECTowner,tablespace_name,SUM(bytes)/ (1024*1024*1024) "GB"FROMdba_segmentsGROUP BYowner,tablespace_name)order by "GB" desc

SYSAUX表領域があふれる

こんな感じのアラートログがよく出る。

ORA-1688: unable to extend table SYS.WRH$_ACTIVE_SESSION_HISTORY partition WRH$_ACTIVE_2116900225_21393 by 128 in                 tablespace SYSAUXORA-1688: unable to extend table SYS.WRH$_ACTIVE_SMMON Flush encountered SYSAUX out of space error(1688).MMON (emergency) purge of WR snapshots (21385) and olderORA-1688: unable to extend table SYS.WRH$_ACTIVE_SESSION_HISTORY partition WRH$_ACTIVE_2116900225_21393 by 128 in                 tablespace SYSAUXORA-1688: unable to extend table SYS.WRH$_ACTIVE_SESSION_HISTORY partition WRH$_ACTIVE_2116900225_21393 by 128 in                 tablespace SYSAUX

これ、ちょっと調べたら http://oraworklog.wordpress.com/2010/07/24/handling-smoptstat-component-growth-in-sysaux-tablespace/ こういう話があって、Oracleのバグ?パッチも出ているらしいが…… 本番は大丈夫?

外部キーというかFKを全て無効化する

BEGINFOR c IN(SELECT c.owner, c.table_name, c.constraint_nameFROM user_constraints c, user_tables tWHERE c.table_name = t.table_nameAND c.status = 'ENABLED'AND c.constraint_type = 'R'ORDER BY c.constraint_type DESC)LOOPdbms_utility.exec_ddl_statement('alter table "' || c.owner || '"."' || c.table_name || '" disable constraint ' || c.constraint_name);END LOOP;END;/

よく読まれている記事

この記事を読んだ人は次の記事も読んでいます:

このエントリーをはてなブックマークに追加
はてなブックマーク - oracle 容量等を調べる
[`google_buzz` not found]
[`yahoo` not found]
[`livedoor` not found]
[`friendfeed` not found]
[`tweetmeme` not found]
[`grow` not found]
[`evernote` not found]

 Posted by at 9:58 AM

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)