{"id":250,"date":"2016-12-09T10:03:24","date_gmt":"2016-12-09T16:03:24","guid":{"rendered":"http:\/\/www.aamirharoon.com\/?p=250"},"modified":"2016-12-09T10:03:24","modified_gmt":"2016-12-09T16:03:24","slug":"awr-warehouse-repository-cleanup","status":"publish","type":"post","link":"http:\/\/www.aamirharoon.com\/?p=250","title":{"rendered":"AWR Warehouse Repository Cleanup"},"content":{"rendered":"<p>Recently I was testing AWR Warehouse functionality at work and had to re-configure the AWR Repository database due to a firewall issue which caused me to change the database port number.  Anyways, when I re-configured the AWR Warehouse database, I didn&#8217;t cleanup or deleted the source databases.<\/p>\n<p>After configuring the AWR Warehouse database in OEM Cloud Control, I noticed that all my source databases were missing and space was not released.  After doing some research and reading the DBSNMP.MGMT_CAW_LOAD package, I found that OEM Cloud Control assigned a new EM_ID when I re-configured the AWR Warehouse repository database.  To find out your AWR Warehouse EM_ID run the following query in OEM Cloud Control repository database or OMR.  Before I re-configured the output was &#8220;1.&#8221;<\/p>\n<pre class=\"brush: sql; gutter: false; title: ; notranslate\" title=\"\">\r\nSQL&gt; SELECT EM_ID FROM sysman.DB_CAW_REPOS\r\n \r\n     EM_ID\r\n----------\r\n         2\r\n\r\n1 row selected.\r\n<\/pre>\n<p>On AWR Warehouse repository database, I queried some %CAW% tables in DBSNMP schema and found out that remnants of EM_ID 1 still exist.<\/p>\n<p>Following query showed two AWR repositories and their properties:<\/p>\n<pre class=\"brush: sql; gutter: false; title: ; notranslate\" title=\"\"> \r\nSQL&gt; SELECT DISTINCT EM_ID\r\n  FROM DBSNMP.CAW_PROPERTIES\r\nWHERE EM_ID IS NOT NULL\r\n \r\n     EM_ID\r\n----------\r\n         1\r\n         2\r\n \r\n2 rows selected.\r\n<\/pre>\n<p>There were two source databases that belonged to EM_ID 1.<\/p>\n<pre class=\"brush: sql; gutter: false; title: ; notranslate\" title=\"\">\r\nSQL&gt; SELECT COUNT(*)\r\nFROM DBSNMP.CAW_SRC_DBS\r\nWHERE EM_ID = 1\r\n \r\n  COUNT(*)\r\n----------\r\n         2\r\n\r\n1 row selected.\r\n<\/pre>\n<p>The data in CAW_SPACE_USAGE table is used to show how much space is being used by AWR Warehouse repository database in OEM Cloud Control dash board.  And since I just re-configured the AWR repository database with having zero source database, the 5GB of used space didn&#8217;t make any sense.<\/p>\n<pre class=\"brush: sql; gutter: false; title: ; notranslate\" title=\"\">\r\nSQL&gt; SELECT TOTAL_SIZE_MB\r\nFROM DBSNMP.CAW_SPACE_USAGE\r\nWHERE UPDATE_DATE &gt; SYSDATE - 2\r\n \r\nTOTAL_SIZE_MB\r\n-------------\r\n         5143\r\n\r\n1 row selected.\r\n<\/pre>\n<p>The DELETED Column in CAW_SRC_DBS tables get updated whenever you delete a source database.  And since EM_ID = 1 is the old AWR Repository, I needed to have following two databases marked deleted.<\/p>\n<pre class=\"brush: sql; gutter: false; title: ; notranslate\" title=\"\">\r\nSQL&gt; COL TARGET_TYPE FORMAT A15\r\nSQL&gt; SELECT CAW_SRC_ID, TARGET_TYPE, DELETED\r\nFROM DBSNMP.CAW_SRC_DBS\r\nWHERE EM_ID = 1\r\n \r\nCAW_SRC_ID TARGET_TYPE     DELETED\r\n---------- --------------- -------\r\n         4 oracle_database N     \r\n         5 oracle_database N     \r\n \r\n2 rows selected.\r\n<\/pre>\n<p>I didn&#8217;t want to manually update all these tables and break something.  And I couldn&#8217;t find any clear answer on the web, so I start reading DBSNMP.MGMT_CAW_LOAD package and found a procedure called &#8220;CELANUP.&#8221;  This procedure truncates the CAW_SPACE_USAGE table, updates CAW_SRC_DBS and deletes rows from CAW_PROPERTIES table.  Exactly what I was looking for \ud83d\ude42<\/p>\n<pre class=\"brush: sql; gutter: false; title: ; notranslate\" title=\"\"> \r\nSQL&gt; EXEC DBSNMP.MGMT_CAW_LOAD.CLEANUP(EM_ID =&gt; 1)\r\n\r\nPL\/SQL procedure successfully completed.\r\n\r\nElapsed: 00:00:00.16\r\n\r\nSQL&gt; COMMIT\r\n\r\nCommit complete.\r\n\r\nElapsed: 00:00:00.11\r\n<\/pre>\n<p>Now there are properties for only one AWR Warehouse:<\/p>\n<pre class=\"brush: sql; gutter: false; title: ; notranslate\" title=\"\"> \r\nSQL&gt; SELECT DISTINCT EM_ID\r\n  FROM DBSNMP.CAW_PROPERTIES\r\nWHERE EM_ID IS NOT NULL\r\n \r\n     EM_ID\r\n----------\r\n         2\r\n\r\n1 row selected.\r\n<\/pre>\n<p>CAW_SPACE_USAGE table was truncated.  But don&#8217;t worry, it gets populated within 5mins by a scheduled job.  Only one row gets inserted in 24 hours and UPDATE_DATE column gets sysdate-1 value.  I am not sure why, but don&#8217;t be surprised if it gets updated with yesterday date.<\/p>\n<pre class=\"brush: sql; gutter: false; title: ; notranslate\" title=\"\">\r\nSQL&gt; SELECT TOTAL_SIZE_MB\r\nFROM DBSNMP.CAW_SPACE_USAGE;\r\n\r\nno rows selected.\r\n<\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/www.aamirharoon.com\/wp-content\/uploads\/2016\/12\/awr_warehouse.png\" alt=\"AWR Warehouse Dashboard\" \/><\/p>\n<p>Now the two tables have been updated with DELETED = Y:<\/p>\n<pre class=\"brush: sql; gutter: false; title: ; notranslate\" title=\"\">\r\nSQL&gt; COL TARGET_TYPE FORMAT A15\r\nSQL&gt; SELECT CAW_SRC_ID, TARGET_TYPE, DELETED\r\nFROM DBSNMP.CAW_SRC_DBS\r\nWHERE EM_ID = 1\r\n \r\nCAW_SRC_ID TARGET_TYPE     DELETED\r\n---------- --------------- -------\r\n         4 oracle_database Y     \r\n         5 oracle_database Y     \r\n \r\n2 rows selected.\r\n<\/pre>\n<p>To find out current space allocated by source databases in AWR Repository, run the following query.  This will give space usage in MB. <\/p>\n<pre class=\"brush: sql; gutter: false; title: ; notranslate\" title=\"\"> \r\nSELECT ROUND (SPACE_USAGE_KBYTES \/ 1024, 2)\r\n  FROM V$SYSAUX_OCCUPANTS\r\nWHERE OCCUPANT_NAME = 'SM\/AWR';\r\n<\/pre>\n<p>If you ever need to re-configure AWR Repository database, make sure to delete all source databases and run the CLEANUP procedure after removing it from OEM Cloud Control.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently I was testing AWR Warehouse functionality at work and had to re-configure the AWR Repository database due to a firewall issue which caused me<\/p>\n","protected":false},"author":1,"featured_media":262,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-250","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oem-cc-12c"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>AWR Warehouse Repository Cleanup - The Database Handyman<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.aamirharoon.com\/?p=250\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"AWR Warehouse Repository Cleanup - The Database Handyman\" \/>\n<meta property=\"og:description\" content=\"Recently I was testing AWR Warehouse functionality at work and had to re-configure the AWR Repository database due to a firewall issue which caused me\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.aamirharoon.com\/?p=250\" \/>\n<meta property=\"og:site_name\" content=\"The Database Handyman\" \/>\n<meta property=\"article:published_time\" content=\"2016-12-09T16:03:24+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.aamirharoon.com\/wp-content\/uploads\/2016\/12\/awr_warehouse.png\" \/>\n\t<meta property=\"og:image:width\" content=\"935\" \/>\n\t<meta property=\"og:image:height\" content=\"217\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Aamir\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@aamir814\" \/>\n<meta name=\"twitter:site\" content=\"@aamir814\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Aamir\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\/\/www.aamirharoon.com\/?p=250#article\",\"isPartOf\":{\"@id\":\"http:\/\/www.aamirharoon.com\/?p=250\"},\"author\":{\"name\":\"Aamir\",\"@id\":\"http:\/\/www.aamirharoon.com\/#\/schema\/person\/dbcd256c4a97c6e27b7cc408200a9b63\"},\"headline\":\"AWR Warehouse Repository Cleanup\",\"datePublished\":\"2016-12-09T16:03:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\/\/www.aamirharoon.com\/?p=250\"},\"wordCount\":744,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/www.aamirharoon.com\/#\/schema\/person\/dbcd256c4a97c6e27b7cc408200a9b63\"},\"image\":{\"@id\":\"http:\/\/www.aamirharoon.com\/?p=250#primaryimage\"},\"thumbnailUrl\":\"http:\/\/www.aamirharoon.com\/wp-content\/uploads\/2016\/12\/awr_warehouse.png\",\"articleSection\":[\"OEM Cloud Control 12c\"],\"inLanguage\":\"en\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"http:\/\/www.aamirharoon.com\/?p=250#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/www.aamirharoon.com\/?p=250\",\"url\":\"http:\/\/www.aamirharoon.com\/?p=250\",\"name\":\"AWR Warehouse Repository Cleanup - The Database Handyman\",\"isPartOf\":{\"@id\":\"http:\/\/www.aamirharoon.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\/\/www.aamirharoon.com\/?p=250#primaryimage\"},\"image\":{\"@id\":\"http:\/\/www.aamirharoon.com\/?p=250#primaryimage\"},\"thumbnailUrl\":\"http:\/\/www.aamirharoon.com\/wp-content\/uploads\/2016\/12\/awr_warehouse.png\",\"datePublished\":\"2016-12-09T16:03:24+00:00\",\"breadcrumb\":{\"@id\":\"http:\/\/www.aamirharoon.com\/?p=250#breadcrumb\"},\"inLanguage\":\"en\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.aamirharoon.com\/?p=250\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en\",\"@id\":\"http:\/\/www.aamirharoon.com\/?p=250#primaryimage\",\"url\":\"http:\/\/www.aamirharoon.com\/wp-content\/uploads\/2016\/12\/awr_warehouse.png\",\"contentUrl\":\"http:\/\/www.aamirharoon.com\/wp-content\/uploads\/2016\/12\/awr_warehouse.png\",\"width\":935,\"height\":217},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/www.aamirharoon.com\/?p=250#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/www.aamirharoon.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"AWR Warehouse Repository Cleanup\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/www.aamirharoon.com\/#website\",\"url\":\"http:\/\/www.aamirharoon.com\/\",\"name\":\"The Database Handyman\",\"description\":\"My notes about Oracle Database, APEX, OEM Cloud Control and whatever I learn\",\"publisher\":{\"@id\":\"http:\/\/www.aamirharoon.com\/#\/schema\/person\/dbcd256c4a97c6e27b7cc408200a9b63\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/www.aamirharoon.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"http:\/\/www.aamirharoon.com\/#\/schema\/person\/dbcd256c4a97c6e27b7cc408200a9b63\",\"name\":\"Aamir\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en\",\"@id\":\"http:\/\/www.aamirharoon.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/63cc5bb07711a1b9719cc47e13a8205072859c1aef30fac28f412baa84b9cf9b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/63cc5bb07711a1b9719cc47e13a8205072859c1aef30fac28f412baa84b9cf9b?s=96&d=mm&r=g\",\"caption\":\"Aamir\"},\"logo\":{\"@id\":\"http:\/\/www.aamirharoon.com\/#\/schema\/person\/image\/\"},\"sameAs\":[\"http:\/\/www.aamirharoon.com\/about\/\",\"https:\/\/x.com\/aamir814\"],\"url\":\"http:\/\/www.aamirharoon.com\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"AWR Warehouse Repository Cleanup - The Database Handyman","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/www.aamirharoon.com\/?p=250","og_locale":"en_US","og_type":"article","og_title":"AWR Warehouse Repository Cleanup - The Database Handyman","og_description":"Recently I was testing AWR Warehouse functionality at work and had to re-configure the AWR Repository database due to a firewall issue which caused me","og_url":"http:\/\/www.aamirharoon.com\/?p=250","og_site_name":"The Database Handyman","article_published_time":"2016-12-09T16:03:24+00:00","og_image":[{"width":935,"height":217,"url":"http:\/\/www.aamirharoon.com\/wp-content\/uploads\/2016\/12\/awr_warehouse.png","type":"image\/png"}],"author":"Aamir","twitter_card":"summary_large_image","twitter_creator":"@aamir814","twitter_site":"@aamir814","twitter_misc":{"Written by":"Aamir","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/www.aamirharoon.com\/?p=250#article","isPartOf":{"@id":"http:\/\/www.aamirharoon.com\/?p=250"},"author":{"name":"Aamir","@id":"http:\/\/www.aamirharoon.com\/#\/schema\/person\/dbcd256c4a97c6e27b7cc408200a9b63"},"headline":"AWR Warehouse Repository Cleanup","datePublished":"2016-12-09T16:03:24+00:00","mainEntityOfPage":{"@id":"http:\/\/www.aamirharoon.com\/?p=250"},"wordCount":744,"commentCount":0,"publisher":{"@id":"http:\/\/www.aamirharoon.com\/#\/schema\/person\/dbcd256c4a97c6e27b7cc408200a9b63"},"image":{"@id":"http:\/\/www.aamirharoon.com\/?p=250#primaryimage"},"thumbnailUrl":"http:\/\/www.aamirharoon.com\/wp-content\/uploads\/2016\/12\/awr_warehouse.png","articleSection":["OEM Cloud Control 12c"],"inLanguage":"en","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["http:\/\/www.aamirharoon.com\/?p=250#respond"]}]},{"@type":"WebPage","@id":"http:\/\/www.aamirharoon.com\/?p=250","url":"http:\/\/www.aamirharoon.com\/?p=250","name":"AWR Warehouse Repository Cleanup - The Database Handyman","isPartOf":{"@id":"http:\/\/www.aamirharoon.com\/#website"},"primaryImageOfPage":{"@id":"http:\/\/www.aamirharoon.com\/?p=250#primaryimage"},"image":{"@id":"http:\/\/www.aamirharoon.com\/?p=250#primaryimage"},"thumbnailUrl":"http:\/\/www.aamirharoon.com\/wp-content\/uploads\/2016\/12\/awr_warehouse.png","datePublished":"2016-12-09T16:03:24+00:00","breadcrumb":{"@id":"http:\/\/www.aamirharoon.com\/?p=250#breadcrumb"},"inLanguage":"en","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.aamirharoon.com\/?p=250"]}]},{"@type":"ImageObject","inLanguage":"en","@id":"http:\/\/www.aamirharoon.com\/?p=250#primaryimage","url":"http:\/\/www.aamirharoon.com\/wp-content\/uploads\/2016\/12\/awr_warehouse.png","contentUrl":"http:\/\/www.aamirharoon.com\/wp-content\/uploads\/2016\/12\/awr_warehouse.png","width":935,"height":217},{"@type":"BreadcrumbList","@id":"http:\/\/www.aamirharoon.com\/?p=250#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/www.aamirharoon.com\/"},{"@type":"ListItem","position":2,"name":"AWR Warehouse Repository Cleanup"}]},{"@type":"WebSite","@id":"http:\/\/www.aamirharoon.com\/#website","url":"http:\/\/www.aamirharoon.com\/","name":"The Database Handyman","description":"My notes about Oracle Database, APEX, OEM Cloud Control and whatever I learn","publisher":{"@id":"http:\/\/www.aamirharoon.com\/#\/schema\/person\/dbcd256c4a97c6e27b7cc408200a9b63"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.aamirharoon.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en"},{"@type":["Person","Organization"],"@id":"http:\/\/www.aamirharoon.com\/#\/schema\/person\/dbcd256c4a97c6e27b7cc408200a9b63","name":"Aamir","image":{"@type":"ImageObject","inLanguage":"en","@id":"http:\/\/www.aamirharoon.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/63cc5bb07711a1b9719cc47e13a8205072859c1aef30fac28f412baa84b9cf9b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/63cc5bb07711a1b9719cc47e13a8205072859c1aef30fac28f412baa84b9cf9b?s=96&d=mm&r=g","caption":"Aamir"},"logo":{"@id":"http:\/\/www.aamirharoon.com\/#\/schema\/person\/image\/"},"sameAs":["http:\/\/www.aamirharoon.com\/about\/","https:\/\/x.com\/aamir814"],"url":"http:\/\/www.aamirharoon.com\/?author=1"}]}},"_links":{"self":[{"href":"http:\/\/www.aamirharoon.com\/index.php?rest_route=\/wp\/v2\/posts\/250","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.aamirharoon.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.aamirharoon.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.aamirharoon.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.aamirharoon.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=250"}],"version-history":[{"count":10,"href":"http:\/\/www.aamirharoon.com\/index.php?rest_route=\/wp\/v2\/posts\/250\/revisions"}],"predecessor-version":[{"id":265,"href":"http:\/\/www.aamirharoon.com\/index.php?rest_route=\/wp\/v2\/posts\/250\/revisions\/265"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.aamirharoon.com\/index.php?rest_route=\/wp\/v2\/media\/262"}],"wp:attachment":[{"href":"http:\/\/www.aamirharoon.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=250"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.aamirharoon.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=250"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.aamirharoon.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}