{"id":2772,"date":"2021-03-17T08:40:52","date_gmt":"2021-03-17T08:40:52","guid":{"rendered":"https:\/\/swiv.com.br\/creating-a-new-pdb-by-cloning-a-local-pdb\/"},"modified":"2026-05-27T20:02:50","modified_gmt":"2026-05-27T19:02:50","slug":"creating-a-new-pdb-by-cloning-a-local-pdb","status":"publish","type":"post","link":"https:\/\/swiv.com.br\/index.php\/2021\/03\/17\/creating-a-new-pdb-by-cloning-a-local-pdb\/","title":{"rendered":"Creating a new PDB by cloning a local PDB"},"content":{"rendered":"\n<p>Antes de ir para a parte pr\u00e1tica, \u00e9 importante mencionar que na vers\u00e3o 12.1, a cria\u00e7\u00e3o de um PDB a partir de um PDB j\u00e1 existente necessitava de downtime, onde a origem precisava estar em READ ONLY:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nALTER PLUGGABLE DATABASE TESTE CLOSE IMMEDIATE;\nALTER PLUGGABLE DATABASE TESTE OPEN READ ONLY;\n<\/pre><\/div>\n\n\n<p>A partir da 12.2, esta opera\u00e7\u00e3o pode ser realizada de forma online, caso o CDB esteja rodando em ARCHIVELOG, e o recurso de LOCAL UNDO esteja habilitado. Como estou na vers\u00e3o 18C, tentarei o m\u00e9todo online:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nSQL&gt; ALTER SESSION SET CONTAINER=CDB$ROOT;\n \nSession altered.\n \nSQL&gt; SELECT BANNER FROM V$VERSION;\n \nBANNER\n--------------------------------------------------------------------------------\nOracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production\n<\/pre><\/div>\n\n\n<p>Verificando que o CDB j\u00e1 est\u00e1 em ARCHIVELOG mode:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nSQL&gt; SELECT LOG_MODE FROM V$DATABASE ;\n \nLOG_MODE\n------------\nARCHIVELOG\n<\/pre><\/div>\n\n\n<p>Checando se o recurso de LOCAL UNDO est\u00e1 habilitado:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nSQL&gt; SELECT PROPERTY_VALUE FROM DATABASE_PROPERTIES WHERE PROPERTY_NAME = &#039;LOCAL_UNDO_ENABLED&#039;;\n \nPROPERTY_VALUE\n-------------------------\nTRUE\n<\/pre><\/div>\n\n\n<p>Validando se o OMF est\u00e1 setado. Em caso positivo, n\u00e3o ser\u00e1 necess\u00e1rio, no comando que ser\u00e1 executado, dizer ao Oracle o local de destino dos datafiles que ser\u00e3o criados:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nSQL&gt; SHOW PARAMETER DB_CREATE_FILE_DEST\n \nNAME                                 TYPE        VALUE\n------------------------------------ ----------- ------------------------------\ndb_create_file_dest                  string      \/oracle\/dados\n<\/pre><\/div>\n\n\n<p>Realizando a cria\u00e7\u00e3o do novo PDB:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nSQL&gt; CREATE PLUGGABLE DATABASE HIPOFISE3 FROM HIPOFISE2;\n \nPluggable database created.\n<\/pre><\/div>\n\n\n<p>Abrindo o PDB:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nSQL&gt; ALTER PLUGGABLE DATABASE HIPOFISE3 OPEN;\n \nPluggable database altered.\n<\/pre><\/div>\n\n\n<p>Consultando os datafiles criados, \u00e9 poss\u00edvel perceber que o OMF criou um diret\u00f3rio novo abaixo do CDB, com o GUID correspondente do novo PDB:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nSQL&gt; set linesize 100\nSQL&gt; col name format a100\nSQL&gt; SELECT NAME FROM V$DATAFILE WHERE CON_ID = ( SELECT CON_ID FROM V$PDBS WHERE NAME=&#039;HIPOFISE3&#039; );\n \nNAME\n----------------------------------------------------------------------------------------------------\n\/oracle\/dados\/TALAMO\/BDB85F2C66111220E0536B00A8C0B35D\/datafile\/o1_mf_system_j53hvf75_.dbf\n\/oracle\/dados\/TALAMO\/BDB85F2C66111220E0536B00A8C0B35D\/datafile\/o1_mf_sysaux_j53hvf7p_.dbf\n\/oracle\/dados\/TALAMO\/BDB85F2C66111220E0536B00A8C0B35D\/datafile\/o1_mf_undotbs1_j53hvf7q_.dbf\n\/oracle\/dados\/TALAMO\/BDB85F2C66111220E0536B00A8C0B35D\/datafile\/o1_mf_users_j53hvf7r_.dbf\n<\/pre><\/div>\n\n\n<p>Realizando teste de conex\u00e3o ao novo PDB com easyconnect:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \\&quot;wp-block-syntaxhighlighter-code\\&quot;\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nSQL&gt; CONN sys\/oracle@oel8.localdomain:1521\/HIPOFISE3.localdomain as SYSDBA\nConnected.\nSQL&gt; SHOW CON_NAME CON_ID;\n \nCON_NAME\n------------------------------\nHIPOFISE3\n \nCON_ID\n------------------------------\n5\n<\/pre><\/div>\n\n\n<p>Obs: Este procedimento foi criado pelo senhor Ahmed Baraka (www.ahmedbaraka.com) e foi apenas reproduzido por mim em um laborat\u00f3rio pessoal para fins de aprendizado.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Antes de ir para a parte pr\u00e1tica, \u00e9 importante mencionar que na vers\u00e3o 12.1, a cria\u00e7\u00e3o de um PDB a partir de um PDB j\u00e1 existente necessitava de downtime, onde a origem precisava estar em READ ONLY: A partir da 12.2, esta opera\u00e7\u00e3o pode ser realizada de forma online, caso o CDB esteja rodando em [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-2772","post","type-post","status-publish","format-standard","hentry","category-multitenant"],"_links":{"self":[{"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/posts\/2772","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/comments?post=2772"}],"version-history":[{"count":1,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/posts\/2772\/revisions"}],"predecessor-version":[{"id":9225,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/posts\/2772\/revisions\/9225"}],"wp:attachment":[{"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/media?parent=2772"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/categories?post=2772"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/tags?post=2772"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}