{"id":9430,"date":"2016-11-28T13:46:14","date_gmt":"2016-11-28T12:46:14","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/oracle-12c-finding-the-dbid-the-last-resort\/"},"modified":"2016-11-28T13:46:14","modified_gmt":"2016-11-28T12:46:14","slug":"oracle-12c-finding-the-dbid-the-last-resort","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/oracle-12c-finding-the-dbid-the-last-resort\/","title":{"rendered":"Oracle 12c &#8211; Finding the DBID &#8211; The last resort"},"content":{"rendered":"<h2>By William Sescu<\/h2>\n<p>The DBID is a very important part for Oracle databases. It is an internal, uniquely generated number that differentiates databases. Oracle creates this number automatically as soon as you create the database.<\/p>\n<p>During normal operation, it is quite easy to find your DBID. Whenever you start your RMAN session, it displays the DBID.<\/p>\n<pre class=\"brush: actionscript3; gutter: true; first-line: 1\">oracle@oel001:\/home\/oracle\/ [OCM121] rman target \/\n\nRecovery Manager: Release 12.1.0.2.0 - Production on Mon Nov 28 10:32:47 2016\n\nCopyright (c) 1982, 2014, Oracle and\/or its affiliates.  All rights reserved.\n\nconnected to target database: OCM121 (DBID=3827054096)\n\nRMAN&gt;<\/pre>\n<p>Or you can just simply select it from your v$database view.<\/p>\n<pre class=\"brush: actionscript3; gutter: true; first-line: 1\">SQL&gt; select DBID from v$database;\n\nDBID\n----------\n3827054096<\/pre>\n<p>But what happens in case you have a restore\/recovery scenario where you lost your database. In the NOMOUNT state, it is not possible to retrieve the DBID.<\/p>\n<pre class=\"brush: actionscript3; gutter: true; first-line: 1\">SQL&gt; select DBID from v$database;\nselect DBID from v$database\n                 *\nERROR at line 1:\nORA-01507: database not mounted<\/pre>\n<p>You can take a look into the alert.log or any other trace file in your DIAG destination, but you will not find a DBID there.<\/p>\n<p>So, if the only thing that you have left is your RMAN Catalog, and your datafile copies in your FRA + Archivelogs, then you need the DBID beforehand, before you can restore\/recover your database correctly.<\/p>\n<p>There are three\u00a0possibilities to get your DBID<\/p>\n<ul>\n<li>You could check your RMAN backup log files, if you have set it up correctly<\/li>\n<li>You could connect to your RMAN catalog and query the &#8220;DB&#8221; table from the catalog owner. Be careful, there might be more than one entry for your DB name, and then it might become difficult to get the correct one. \u00a0In my example, I have only one entry\n<pre class=\"brush: actionscript3; gutter: true; first-line: 1\">SQL&gt; select * from db;\n\n    DB_KEY      DB_ID REG_DB_UNIQUE_NAME             CURR_DBINC_KEY S\n---------- ---------- ------------------------------ -------------- -\n         1 3827054096 OCM121                                      2 N<\/pre>\n<\/li>\n<li>And as the last resort, you can startup nomount (either with a backup pfile or with the RMAN dummy instance), and afterwards you can dump out the header of your datafile copies in your FRA<\/li>\n<\/ul>\n<p>Dumping out the first block is usually enough, and besides that, you are not limited to the SYSTEM datafile. You can use any of your datafile copies in your FRA (like SYSAUX, USERS and so on) to dump out the block, like shown in the following example:<\/p>\n<pre class=\"brush: actionscript3; gutter: true; first-line: 1\">-- Dump the first block from the SYSTEM datafile\nSQL&gt; alter session set tracefile_identifier = dbid_system;\nSession altered.\n\nSQL&gt; alter system dump datafile '+fra\/OCM121\/datafile\/SYSTEM.457.926419155' block min 1 block max 1;\nSystem altered.\n\noracle@oel001:\/u00\/app\/oracle\/diag\/rdbms\/ocm121\/OCM121\/trace\/ [OCM121] cat OCM121_ora_6459_DBID_SYSTEM.trc | grep \"Db ID\"\n        Db ID=3827054096=0xe41c3610, Db Name='OCM121'\n\n-- Dump the first block from the SYSAUX datafile\t\t\nSQL&gt; alter session set tracefile_identifier = dbid_sysaux;\nSession altered.\n\nSQL&gt; alter system dump datafile '+fra\/OCM121\/datafile\/SYSAUX.354.926417851' block min 1 block max 1;\nSystem altered.\n\noracle@oel001:\/u00\/app\/oracle\/diag\/rdbms\/ocm121\/OCM121\/trace\/ [OCM121] cat OCM121_ora_7035_DBID_SYSAUX.trc | grep \"Db ID\"\n        Db ID=3827054096=0xe41c3610, Db Name='OCM121'\n\n-- Dump the first block from the USERS datafile\nSQL&gt; alter session set tracefile_identifier = dbid_users;\nSession altered.\n\nSQL&gt; alter system dump datafile '+fra\/OCM121\/datafile\/USERS.533.926419511' block min 1 block max 1;\nSystem altered.\n\noracle@oel001:\/u00\/app\/oracle\/diag\/rdbms\/ocm121\/OCM121\/trace\/ [OCM121] cat OCM121_ora_7064_DBID_USERS.trc | grep \"Db ID\"\n        Db ID=3827054096=0xe41c3610, Db Name='OCM121'<\/pre>\n<p>As soon as you have your DBID, it is straight forward to do the rest. Connect to your target and RMAN catalog, set the DBID and then run your restore, recovery scripts.<\/p>\n<pre class=\"brush: actionscript3; gutter: true; first-line: 1\">rman target sys\/manager catalog rman\/rman@rman\nset dbid=3827054096\nrun {\nrestore spfile from autobackup;\n}\n\nrun {\nrestore controlfile ....\n}\n\nrun {\nrestore database ....\nrecover database ....\n}<\/pre>\n<h3>Conclusion<\/h3>\n<p>Don&#8217;t forget to save your DBID with your RMAN backup jobs somewhere. Recovering a database at 3 o&#8217;clock in the morning with a missing DBID might become a nightmare.<br \/>\nCheers,<br \/>\nWilliam<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By William Sescu The DBID is a very important part for Oracle databases. It is an internal, uniquely generated number that differentiates databases. Oracle creates this number automatically as soon as you create the database. During normal operation, it is quite easy to find your DBID. Whenever you start your RMAN session, it displays the [&hellip;]<\/p>\n","protected":false},"author":27,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[229],"tags":[209,270],"type_dbi":[],"class_list":["post-9430","post","type-post","status-publish","format-standard","hentry","category-database-administration-monitoring","tag-oracle-12c","tag-rman"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.2) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Oracle 12c - Finding the DBID - The last resort - dbi Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbi-services.com\/blog\/oracle-12c-finding-the-dbid-the-last-resort\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Oracle 12c - Finding the DBID - The last resort\" \/>\n<meta property=\"og:description\" content=\"By William Sescu The DBID is a very important part for Oracle databases. It is an internal, uniquely generated number that differentiates databases. Oracle creates this number automatically as soon as you create the database. During normal operation, it is quite easy to find your DBID. Whenever you start your RMAN session, it displays the [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/oracle-12c-finding-the-dbid-the-last-resort\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi Blog\" \/>\n<meta property=\"article:published_time\" content=\"2016-11-28T12:46:14+00:00\" \/>\n<meta name=\"author\" content=\"Oracle Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Oracle Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/oracle-12c-finding-the-dbid-the-last-resort\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/oracle-12c-finding-the-dbid-the-last-resort\/\"},\"author\":{\"name\":\"Oracle Team\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/66ab87129f2d357f09971bc7936a77ee\"},\"headline\":\"Oracle 12c &#8211; Finding the DBID &#8211; The last resort\",\"datePublished\":\"2016-11-28T12:46:14+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/oracle-12c-finding-the-dbid-the-last-resort\/\"},\"wordCount\":386,\"commentCount\":0,\"keywords\":[\"Oracle 12c\",\"RMAN\"],\"articleSection\":[\"Database Administration &amp; Monitoring\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/oracle-12c-finding-the-dbid-the-last-resort\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/oracle-12c-finding-the-dbid-the-last-resort\/\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/oracle-12c-finding-the-dbid-the-last-resort\/\",\"name\":\"Oracle 12c - Finding the DBID - The last resort - dbi Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\"},\"datePublished\":\"2016-11-28T12:46:14+00:00\",\"author\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/66ab87129f2d357f09971bc7936a77ee\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/oracle-12c-finding-the-dbid-the-last-resort\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/oracle-12c-finding-the-dbid-the-last-resort\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/oracle-12c-finding-the-dbid-the-last-resort\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\/\/www.dbi-services.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Oracle 12c &#8211; Finding the DBID &#8211; The last resort\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/\",\"name\":\"dbi Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/66ab87129f2d357f09971bc7936a77ee\",\"name\":\"Oracle Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/f711f7cd2c9b09bf2627133755b569fb5be0694810cfd33033bdd095fedba86d?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f711f7cd2c9b09bf2627133755b569fb5be0694810cfd33033bdd095fedba86d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/f711f7cd2c9b09bf2627133755b569fb5be0694810cfd33033bdd095fedba86d?s=96&d=mm&r=g\",\"caption\":\"Oracle Team\"},\"url\":\"https:\/\/www.dbi-services.com\/blog\/author\/oracle-team\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Oracle 12c - Finding the DBID - The last resort - dbi Blog","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":"https:\/\/www.dbi-services.com\/blog\/oracle-12c-finding-the-dbid-the-last-resort\/","og_locale":"en_US","og_type":"article","og_title":"Oracle 12c - Finding the DBID - The last resort","og_description":"By William Sescu The DBID is a very important part for Oracle databases. It is an internal, uniquely generated number that differentiates databases. Oracle creates this number automatically as soon as you create the database. During normal operation, it is quite easy to find your DBID. Whenever you start your RMAN session, it displays the [&hellip;]","og_url":"https:\/\/www.dbi-services.com\/blog\/oracle-12c-finding-the-dbid-the-last-resort\/","og_site_name":"dbi Blog","article_published_time":"2016-11-28T12:46:14+00:00","author":"Oracle Team","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Oracle Team","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/oracle-12c-finding-the-dbid-the-last-resort\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/oracle-12c-finding-the-dbid-the-last-resort\/"},"author":{"name":"Oracle Team","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/66ab87129f2d357f09971bc7936a77ee"},"headline":"Oracle 12c &#8211; Finding the DBID &#8211; The last resort","datePublished":"2016-11-28T12:46:14+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/oracle-12c-finding-the-dbid-the-last-resort\/"},"wordCount":386,"commentCount":0,"keywords":["Oracle 12c","RMAN"],"articleSection":["Database Administration &amp; Monitoring"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/oracle-12c-finding-the-dbid-the-last-resort\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/oracle-12c-finding-the-dbid-the-last-resort\/","url":"https:\/\/www.dbi-services.com\/blog\/oracle-12c-finding-the-dbid-the-last-resort\/","name":"Oracle 12c - Finding the DBID - The last resort - dbi Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"datePublished":"2016-11-28T12:46:14+00:00","author":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/66ab87129f2d357f09971bc7936a77ee"},"breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/oracle-12c-finding-the-dbid-the-last-resort\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/oracle-12c-finding-the-dbid-the-last-resort\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/oracle-12c-finding-the-dbid-the-last-resort\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Oracle 12c &#8211; Finding the DBID &#8211; The last resort"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/66ab87129f2d357f09971bc7936a77ee","name":"Oracle Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/f711f7cd2c9b09bf2627133755b569fb5be0694810cfd33033bdd095fedba86d?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f711f7cd2c9b09bf2627133755b569fb5be0694810cfd33033bdd095fedba86d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f711f7cd2c9b09bf2627133755b569fb5be0694810cfd33033bdd095fedba86d?s=96&d=mm&r=g","caption":"Oracle Team"},"url":"https:\/\/www.dbi-services.com\/blog\/author\/oracle-team\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/9430","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/27"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=9430"}],"version-history":[{"count":0,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/9430\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=9430"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=9430"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=9430"},{"taxonomy":"type","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/type_dbi?post=9430"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}