{"id":1939,"date":"2020-05-14T18:18:10","date_gmt":"2020-05-14T16:18:10","guid":{"rendered":"http:\/\/www.ludovicocaldara.net\/dba\/?p=1939"},"modified":"2024-01-03T11:20:59","modified_gmt":"2024-01-03T09:20:59","slug":"mt-pills-change-pdb-id","status":"publish","type":"post","link":"https:\/\/www.ludovicocaldara.net\/dba\/mt-pills-change-pdb-id\/","title":{"rendered":"Multitenant Pills &#8211; Change DBID for an existing PDB"},"content":{"rendered":"<p>When you plug the same PDB many times you have to specify &#8220;AS COPY&#8221; in the syntax:<\/p>\n<pre class=\"lang:plsql decode:true\">CREATE PLUGGABLE DATABASE ludo AS CLONE USING '\/u01\/app\/oradata\/ludo\/ludo.xml';<\/pre>\n<p>Otherwise, you will get an error similar to:<\/p>\n<pre class=\"lang:plsql decode:true \">ERROR at line 1:\r\nORA-65122: Pluggable database GUID conflicts with the GUID of an existing container.<\/pre>\n<p>There are cases, however, where you cannot do it. For example, it the existing PDB should have been the clone, or if you are converting a copy of the same database from Non-CDB to PDB using autoupgrade (with autoupgrade you cannot modify the CREATE PLUGGABLE DATABASE statement).<\/p>\n<p>In this case, the solution might be to change the DBID of the existing PDB, via unplug\/plug:<\/p>\n<pre class=\"lang:plsql decode:true\">ALTER PLUGGABLE DATABASE vico CLOSE;\r\nALTER PLUGGABLE DATABASE vico UNPLUG INTO '\/u01\/app\/oradata\/ludo\/ludo.xml';\r\nDROP PLUGGABLE DATABASE vico KEEP DATAFILES;\r\nCREATE PLUGGABLE DATABASE vico AS CLONE  USING '\/u01\/app\/oradata\/ludo\/ludo.xml' NOCOPY;\r\nALTER  PLUGGABLE DATABASE vico OPEN;\r\nALTER  PLUGGABLE DATABASE vico SAVE STATE;<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>EDIT 2024-01-03: <\/strong>If you use Transparent Data Encryption, you have to export the key before you can unplug the PDB, or you will encounter:<\/p>\n<pre class=\"lang:plsql decode:true\">ORA-46680: master keys of the container database must be exported<\/pre>\n<p>Before closing the PDB, just run:<\/p>\n<pre class=\"lang:plsql decode:true\">alter session set container=vico;\r\n\r\nADMINISTER KEY MANAGEMENT EXPORT ENCRYPTION KEYS WITH SECRET \"secret\"\r\nTO '\/secure_path\/ludo.p12' FORCE KEYSTORE IDENTIFIED BY \"secret\" ;\r\n\r\nalter session set container=cdb$root;<\/pre>\n<p>After opening the PDB, you&#8217;ll need to import the key again:<\/p>\n<pre class=\"lang:plsql decode:true\">alter session set container=vico;\r\n\r\nADMINISTER KEY MANAGEMENT IMPORT ENCRYPTION KEYS WITH SECRET \"secret\"\r\nFROM '\/secure_path\/ludo.p12' FORCE KEYSTORE IDENTIFIED BY \"secret\"\r\nWITH BACKUP USING 'plug_vico';\r\n<\/pre>\n<p>Don&#8217;t forget to keep your master key exports in a secure place.<\/p>\n<p>&#8212;<\/p>\n<p>Ludo<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When you plug the same PDB many times you have to specify &#8220;AS COPY&#8221; in the syntax: CREATE PLUGGABLE DATABASE ludo AS CLONE USING &#8216;\/u01\/app\/oradata\/ludo\/ludo.xml&#8217;; Otherwise, you will get an error similar to: ERROR at line 1: ORA-65122: Pluggable database &hellip; <a href=\"https:\/\/www.ludovicocaldara.net\/dba\/mt-pills-change-pdb-id\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[326,3,315,328,132],"tags":[],"class_list":["post-1939","post","type-post","status-publish","format-standard","hentry","category-oracle","category-oracledb","category-oracle-database-19c","category-oracle-mt","category-triblog"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts\/1939","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/comments?post=1939"}],"version-history":[{"count":4,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts\/1939\/revisions"}],"predecessor-version":[{"id":2233,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts\/1939\/revisions\/2233"}],"wp:attachment":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/media?parent=1939"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/categories?post=1939"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/tags?post=1939"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}