{"id":97,"date":"2026-06-01T10:30:18","date_gmt":"2026-06-01T02:30:18","guid":{"rendered":"https:\/\/yuriblog.online\/?p=97"},"modified":"2026-06-01T10:30:19","modified_gmt":"2026-06-01T02:30:19","slug":"oracle%e6%b8%85%e7%90%86%e8%be%85%e5%8a%a9%e8%a1%a8%e7%a9%ba%e9%97%b4","status":"publish","type":"post","link":"https:\/\/yuriblog.online\/index.php\/2026\/06\/01\/oracle%e6%b8%85%e7%90%86%e8%be%85%e5%8a%a9%e8%a1%a8%e7%a9%ba%e9%97%b4\/","title":{"rendered":"oracle\u6e05\u7406\u8f85\u52a9\u8868\u7a7a\u95f4"},"content":{"rendered":"\n<p>\u67e5\u8be2\u8868\u7a7a\u95f4\u4f7f\u7528\u7387\u53d1\u73b0\u8f85\u52a9\u8868\u7a7a\u95f4\u4f7f\u7528\u7387\u504f\u9ad8<\/p>\n\n\n\n<p>set&nbsp;linesize&nbsp;180;<br>set&nbsp;pagesize&nbsp;999;<br>col&nbsp;tablespace_name&nbsp;for&nbsp;a30<br>col&nbsp;extent_mg&nbsp;for&nbsp;a10<br>col&nbsp;&#8220;tot_space\/G&#8221;&nbsp;for&nbsp;a15<br>col&nbsp;&#8220;used\/G&#8221;&nbsp;for&nbsp;a10<br>col&nbsp;&#8220;free\/G&#8221;&nbsp;for&nbsp;a10<br>col&nbsp;&#8220;usage%&#8221;&nbsp;for&nbsp;a10<br>select&nbsp;a.tablespace_name,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;round(a.bytes&nbsp;\/&nbsp;1024&nbsp;\/&nbsp;1024&nbsp;\/&nbsp;&nbsp;1024,&nbsp;0)&nbsp;&#8220;sum&nbsp;G&#8221;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;round((a.bytes&nbsp;&#8211;&nbsp;b.bytes)&nbsp;\/&nbsp;1024&nbsp;\/&nbsp;&nbsp;1024&nbsp;\/&nbsp;1024,&nbsp;0)&nbsp;&#8220;used&nbsp;G&#8221;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;round(b.bytes&nbsp;\/&nbsp;1024&nbsp;\/&nbsp;1024&nbsp;\/&nbsp;&nbsp;1024,&nbsp;0)&nbsp;&#8220;free&nbsp;G&#8221;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;round(((a.bytes&nbsp;&#8211;&nbsp;b.bytes)&nbsp;\/&nbsp;&nbsp;a.bytes)&nbsp;*&nbsp;100,&nbsp;2)&nbsp;&#8220;used%&#8221;<br>&nbsp;&nbsp;from&nbsp;(select&nbsp;tablespace_name,&nbsp;&nbsp;sum(bytes)&nbsp;bytes<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from&nbsp;dba_data_files<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;group&nbsp;by&nbsp;tablespace_name)&nbsp;a,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(select&nbsp;tablespace_name,&nbsp;&nbsp;sum(bytes)&nbsp;bytes,&nbsp;max(bytes)&nbsp;largest<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from&nbsp;dba_free_space<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;group&nbsp;by&nbsp;tablespace_name)&nbsp;b<br>where&nbsp;a.tablespace_name&nbsp;=&nbsp;&nbsp;b.tablespace_name<br>order&nbsp;by&nbsp;((a.bytes&nbsp;&#8211;&nbsp;b.bytes)&nbsp;\/&nbsp;a.bytes)&nbsp;&nbsp;desc;<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"714\" height=\"161\" src=\"https:\/\/yuriblog.online\/wp-content\/uploads\/2026\/06\/image.png\" alt=\"\" class=\"wp-image-98\" srcset=\"https:\/\/yuriblog.online\/wp-content\/uploads\/2026\/06\/image.png 714w, https:\/\/yuriblog.online\/wp-content\/uploads\/2026\/06\/image-300x68.png 300w\" sizes=\"auto, (max-width: 714px) 100vw, 714px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\u5b9a\u4f4d\u5360\u7528\u7a7a\u95f4\u7684\u5bf9\u8c61<\/strong><\/h4>\n\n\n\n<p>col&nbsp;OCCUPANT_NAME&nbsp;for&nbsp;a30<br>SELECT&nbsp;occupant_name,&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;space_usage_kbytes&nbsp;\/&nbsp;1024&nbsp;AS&nbsp;space_used_mb,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;schema_name,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;move_procedure<br>FROM&nbsp;v$sysaux_occupants<br>ORDER&nbsp;BY&nbsp;space_usage_kbytes&nbsp;DESC;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"468\" src=\"https:\/\/yuriblog.online\/wp-content\/uploads\/2026\/06\/image-1-1024x468.png\" alt=\"\" class=\"wp-image-99\" srcset=\"https:\/\/yuriblog.online\/wp-content\/uploads\/2026\/06\/image-1-1024x468.png 1024w, https:\/\/yuriblog.online\/wp-content\/uploads\/2026\/06\/image-1-300x137.png 300w, https:\/\/yuriblog.online\/wp-content\/uploads\/2026\/06\/image-1-768x351.png 768w, https:\/\/yuriblog.online\/wp-content\/uploads\/2026\/06\/image-1.png 1468w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\u67e5\u770b\u5177\u4f53\u5bf9\u8c61\u5927\u5c0f<\/strong><\/h4>\n\n\n\n<p>select&nbsp;OWNER,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;segment_name,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;segment_type,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PARTITION_NAME,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bytes&nbsp;\/&nbsp;1024&nbsp;\/&nbsp;1024&nbsp;\/&nbsp;1024&nbsp;Size_GB<br>&nbsp;&nbsp;from&nbsp;dba_segments<br>&nbsp;where&nbsp;tablespace_name&nbsp;=&nbsp;&#8216;SYSAUX&#8217;<br>&nbsp;order&nbsp;by&nbsp;Size_GB&nbsp;desc<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"453\" src=\"https:\/\/yuriblog.online\/wp-content\/uploads\/2026\/06\/image-2-1024x453.png\" alt=\"\" class=\"wp-image-100\" srcset=\"https:\/\/yuriblog.online\/wp-content\/uploads\/2026\/06\/image-2-1024x453.png 1024w, https:\/\/yuriblog.online\/wp-content\/uploads\/2026\/06\/image-2-300x133.png 300w, https:\/\/yuriblog.online\/wp-content\/uploads\/2026\/06\/image-2-768x340.png 768w, https:\/\/yuriblog.online\/wp-content\/uploads\/2026\/06\/image-2.png 1492w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><code>\u53d1\u73b0WRH$_ACTIVE_SESSION_HISTORY<\/code>\u548c<code>WRH$_EVENT_HISTOGRAM<\/code>\u7b49AWR\u76f8\u5173\u8868\u5360\u7528\u5927\u91cf\u7a7a\u95f4<\/p>\n\n\n\n<p>WRH$_ACTIVE_SESSION_HISTORY\uff1a\u4e0eAWR\u76f8\u5173\uff0c\u5b58\u653e\u6d3b\u52a8\u4f1a\u8bdd\u5386\u53f2<\/p>\n\n\n\n<p>WRH$_EVENT_HISTOGRAM\uff1a\u8bb0\u5f55\u7b49\u5f85 \u4e8b\u4ef6 \u76f4\u65b9\u56fe<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u4e8c\u3001\u89e3\u51b3\u65b9\u6848\uff1a\u6e05\u7406AWR\u5386\u53f2\u6570\u636e<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">1\u3001<strong>\u6e05\u7406\u7279\u5b9a\u5206\u533a\u6570\u636e<\/strong><\/h4>\n\n\n\n<p>ALTER&nbsp;TABLE&nbsp;WRH$_ACTIVE_SESSION_HISTORY&nbsp;TRUNCATE&nbsp;PARTITION&nbsp;WRH$_ACTIVE_1643269296_0;&nbsp;&nbsp;&nbsp;<\/p>\n\n\n\n<p>\u4e5f\u53ef\u4ee5\u4f7f\u7528<\/p>\n\n\n\n<p>truncate&nbsp;table&nbsp;WRH$_ACTIVE_SESSION_HISTORY;<br>truncate&nbsp;table&nbsp;WRH$_EVENT_HISTOGRAM;&nbsp;<\/p>\n\n\n\n<p>\u6216<\/p>\n\n\n\n<p>execute&nbsp;dbms_workload_repository.drop_snapshot_range(low_snap_id&nbsp;=&gt;&nbsp;0,&nbsp;high_snap_id&nbsp;=&gt;&nbsp;99999999);&nbsp;<br>execute&nbsp;dbms_workload_repository.purge_histogram_history;<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">2\u3001<strong>\u9a8c\u8bc1\u6e05\u7406\u7ed3\u679c<\/strong><\/h4>\n\n\n\n<p>\u5df2\u91ca\u653e<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"699\" height=\"154\" src=\"https:\/\/yuriblog.online\/wp-content\/uploads\/2026\/06\/image-3.png\" alt=\"\" class=\"wp-image-101\" srcset=\"https:\/\/yuriblog.online\/wp-content\/uploads\/2026\/06\/image-3.png 699w, https:\/\/yuriblog.online\/wp-content\/uploads\/2026\/06\/image-3-300x66.png 300w\" sizes=\"auto, (max-width: 699px) 100vw, 699px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u67e5\u8be2\u8868\u7a7a\u95f4\u4f7f\u7528\u7387\u53d1\u73b0\u8f85\u52a9\u8868\u7a7a\u95f4\u4f7f\u7528\u7387\u504f\u9ad8 set&nbsp;linesize&nbsp;180;set&#038;nbs [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-97","post","type-post","status-publish","format-standard","hentry","category-oracle"],"_links":{"self":[{"href":"https:\/\/yuriblog.online\/index.php\/wp-json\/wp\/v2\/posts\/97","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yuriblog.online\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yuriblog.online\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yuriblog.online\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yuriblog.online\/index.php\/wp-json\/wp\/v2\/comments?post=97"}],"version-history":[{"count":1,"href":"https:\/\/yuriblog.online\/index.php\/wp-json\/wp\/v2\/posts\/97\/revisions"}],"predecessor-version":[{"id":102,"href":"https:\/\/yuriblog.online\/index.php\/wp-json\/wp\/v2\/posts\/97\/revisions\/102"}],"wp:attachment":[{"href":"https:\/\/yuriblog.online\/index.php\/wp-json\/wp\/v2\/media?parent=97"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yuriblog.online\/index.php\/wp-json\/wp\/v2\/categories?post=97"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yuriblog.online\/index.php\/wp-json\/wp\/v2\/tags?post=97"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}