SlideShare una empresa de Scribd logo
1 de 3
Descargar para leer sin conexión
Articles from Database administrator
workshop
How to create a PDB from a Non-CDB using
DBMS_PDB package
To test this scenario I have recently created using DBCA a non container database
named ORCL. CDB001 and CDBTEST are instead two container databases.
view plainprint?
1. [oracle@vsi08devpom ~]$ ps -ef|grep smon
2. oracle 4081 1 0 Jul15 ? 00:01:30 ora_smon_CDB001
3. oracle 11394 1 0 10:20 ? 00:00:00 ora_smon_ORCL
4. oracle 12586 9609 0 10:46 pts/0 00:00:00 grep smon
5. oracle 16455 1 0 Jul17 ? 00:01:34 ora_smon_CDBTEST
I want to consolidate this database plugging it into a container database.
In this scenario I'm going to use the DBMS_PDB package to create the XML file
with the metadata of ORCL database.
Before using the DBMS_PDB.DESCRIBE procedure, the ORCL database needs
to be in READ ONLY mode.
view plainprint?
1. [oracle@vsi08devpom ~]$ export ORACLE_SID=ORCL
2. [oracle@vsi08devpom ~]$ sqlplus / as sysdba
3.
4. SQL*Plus: Release 12.1.0.1.0 Production on Wed Aug 7 10:47:29 2013
5.
6. Copyright (c) 1982, 2013, Oracle. All rights reserved.
7.
8. Connected to:
9. Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 -
64bit Production
10. With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
11.
12. SQL@ORCL> show con_name;
13.
14. CON_NAME
15. ------------------------------
16. Non Consolidated
17. SQL@ORCL> select name, open_mode from V$DATABASE;
18.
19. NAME OPEN_MODE
20. --------- --------------------
21. ORCL READ WRITE
22.
23. SQL@ORCL> shutdown immediate;
24. Database closed.
25. Database dismounted.
26. ORACLE instance shut down.
27.
28. SQL@ORCL> startup mount;
29. ORACLE instance started.
30.
31. Total System Global Area 471830528 bytes
32. Fixed Size 2289688 bytes
33. Variable Size 264245224 bytes
34. Database Buffers 197132288 bytes
35. Redo Buffers 8163328 bytes
36. Database mounted.
37. SQL@ORCL> alter database open read only;
38.
39. Database altered.
view plainprint?
1. SQL@ORCL> begin
2. 2 dbms_pdb.describe( pdb_descr_file => '/opt/app/oracle/oradata/orcl.xml');
3. 3 end;
4. 4 /
5.
6. PL/SQL procedure successfully completed.
7.
8. SQL@ORCL> host ls /opt/app/oracle/oradata/orcl*
9. /opt/app/oracle/oradata/orcl.xml
10.
11. SQL@ORCL> shutdown immediate;
12. Database closed.
13. Database dismounted.
14. ORACLE instance shut down.
15. SQL@ORCL> exit
Now connect to the container database. In my case I want to plug ORCL database
into the CDBTEST container. It currently contains 4 pluggable databases.
view plainprint?
1. [oracle@vsi08devpom ~]$ export ORACLE_SID=CDBTEST
2. [oracle@vsi08devpom ~]$ sqlplus / as sysdba
3.
4. SQL*Plus: Release 12.1.0.1.0 Production on Wed Aug 7 11:07:12 2013
5.
6. Copyright (c) 1982, 2013, Oracle. All rights reserved.
7.
8. Connected to:
9. Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 -
64bit Production
10. With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
11.
12. SQL@CDBTEST> show con_name;
13.
14. CON_NAME
15. ------------------------------
16. CDB$ROOT
17.
18. SQL@CDBTEST> select name, open_mode from V$PDBS;
19.
20. NAME OPEN_MODE
21. ------------------------------ ----------
22. PDB$SEED READ ONLY
23. PDBTEST1 READ WRITE
24. PDBTEST2 READ WRITE
25. PDBTEST3 READ WRITE
26. PDB003 READ ONLY
Here is the situation of the directories for the CDBTEST container database:
view plainprint?
1. [oracle@vsi08devpom ~]$ cd /opt/app/oracle/oradata/CDBTEST/
2. [oracle@vsi08devpom CDBTEST]$ ll
3. total 3459784
4. -rw-r----- 1 oracle oinstall 17973248 Aug 7 11:13 control01.ctl
5. drwxr-x--- 2 oracle oinstall 4096 Aug 1 14:54 PDB003
6. drwxr-x--- 2 oracle oinstall 4096 Jul 17 11:25 pdbseed
7. drwxr-x--- 2 oracle oinstall 4096 Jul 17 13:16 PDBTEST1
8. drwxr-x--- 2 oracle oinstall 4096 Jul 17 13:17 PDBTEST2
9. drwxr-x--- 2 oracle oinstall 4096 Jul 17 13:18 PDBTEST3
10. -rw-r----- 1 oracle oinstall 52429312 Aug 7 11:12 redo01.log
11. -rw-r----- 1 oracle oinstall 52429312 Aug 7 00:16 redo02.log
12. -rw-r----- 1 oracle oinstall 52429312 Aug 7 06:00 redo03.log
13. -rw-r----- 1 oracle oinstall 1310728192 Aug 7 11:12 sysaux01.dbf
14. -rw-r----- 1 oracle oinstall 828383232 Aug 7 11:12 system01.dbf
15. -rw-r----- 1 oracle oinstall 63971328 Aug 7 11:01 temp01.dbf
16. -rw-r----- 1 oracle oinstall 1205870592 Aug 7 11:12 undotbs01.dbf
17. -rw-r----- 1 oracle oinstall 5251072 Aug 7 06:05 users01.dbf
Now you can plug the ORCL database into the CDBTEST container database using
the usual syntax (have a look at this post)
view plainprint?
1. SQL@CDBTEST> create pluggable database ORCL using '/opt/app/oracle/oradata/orcl.xml' copy file_name_convert=('/opt/app/oracle/oradata/ORCL','/opt/app/oracle/oradata/CDBTEST/ORCL');
2.
3. Pluggable database created.
The Oracle software copies under the directory
/opt/app/oracle/oradata/CDBTEST/ORCL all the datafiles coming from
/opt/app/oracle/oradata/ORCL location.
view plainprint?
1. [oracle@vsi08devpom CDBTEST]$ ll
2. total 3459788
3. -rw-r----- 1 oracle oinstall 17973248 Aug 7 12:10 control01.ctl
4. drwxr-x--- 2 oracle oinstall 4096 Aug 7 11:49 ORCL
5. drwxr-x--- 2 oracle oinstall 4096 Aug 1 14:54 PDB003
6. drwxr-x--- 2 oracle oinstall 4096 Jul 17 11:25 pdbseed
7. drwxr-x--- 2 oracle oinstall 4096 Jul 17 13:16 PDBTEST1
8. drwxr-x--- 2 oracle oinstall 4096 Jul 17 13:17 PDBTEST2
9. drwxr-x--- 2 oracle oinstall 4096 Jul 17 13:18 PDBTEST3
10. -rw-r----- 1 oracle oinstall 52429312 Aug 7 12:10 redo01.log
11. -rw-r----- 1 oracle oinstall 52429312 Aug 7 00:16 redo02.log
12. -rw-r----- 1 oracle oinstall 52429312 Aug 7 06:00 redo03.log
13. -rw-r----- 1 oracle oinstall 1310728192 Aug 7 12:10 sysaux01.dbf
14. -rw-r----- 1 oracle oinstall 828383232 Aug 7 12:07 system01.dbf
15. -rw-r----- 1 oracle oinstall 63971328 Aug 7 12:03 temp01.dbf
16. -rw-r----- 1 oracle oinstall 1205870592 Aug 7 12:10 undotbs01.dbf
17. -rw-r----- 1 oracle oinstall 5251072 Aug 7 06:05 users01.dbf
A new pluggable database is created with a NEW status
view plainprint?
1. SQL@CDBTEST> select pdb_id, pdb_name, dbid, status, creation_scn, con_id from CDB_PDBS;
2.
3. PDB_ID PDB_NAME DBID STATUS CREATION_SCN CON_ID
4. ---------- ---------- ---------- ------------- ------------ ----------
5. 2 PDB$SEED 4063610283 NORMAL 217 1
6. 3 PDBTEST1 3064465721 NORMAL 1547881 1
7. 4 PDBTEST2 2395404598 NORMAL 1548944 1
8. 5 PDBTEST3 2434165039 NORMAL 1550036 1
9. 6 PDB003 1448206714 NORMAL 2744910 1
10. 7 ORCL 1350603571 NEW 3226095 1
It's still not the time to open the new PDB.
You need first to execute, while connected to the new pluggable database, the
script $ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql:
view plainprint?
1. [oracle@vsi08devpom CDBTEST]$ ll /opt/app/oracle/product/12.1.0/db_1/rdbms/admin/noncdb_to_pdb.sql
2. -rw-r--r--
1 oracle oinstall 19191 Apr 15 22:27 /opt/app/oracle/product/12.1.0/db_1/rdbms/admin/noncdb_to_pdb.sql
3.
4. SQL@CDBTEST> alter session set container=ORCL;
5.
6. Session altered.
7.
8. SQL@CDBTEST> @/opt/app/oracle/product/12.1.0/db_1/rdbms/admin/noncdb_to_pdb.sql
9. SQL@CDBTEST> SET SERVEROUTPUT ON
10. SQL@CDBTEST> SET FEEDBACK 1
11. SQL@CDBTEST> SET NUMWIDTH 10
12. ...
13. ...
14. ...
15. SQL@CDBTEST> --
leave the PDB in the same state it was when we started
16. SQL@CDBTEST> BEGIN
17. 2 execute immediate '&open_sql &restricted_state';
18. 3 EXCEPTION
19. 4 WHEN OTHERS THEN
20. 5 BEGIN
21. 6 IF (sqlcode <> -900) THEN
22. 7 RAISE;
23. 8 END IF;
24. 9 END;
25. 10 END;
26. 11 /
27.
28. PL/SQL procedure successfully completed.
29.
30. SQL@CDBTEST>
31. SQL@CDBTEST> WHENEVER SQLERROR CONTINUE;
32. SQL@CDBTEST>
Now you can open the new ORCL pluggable database.
view plainprint?
1. SQL@CDBTEST> show con_name;
2.
3. CON_NAME
4. ------------------------------
5. ORCL
6. SQL@CDBTEST> alter database open;
7.
8. Database altered.
The database is so available and ready to be used.
view plainprint?
1. SQL@CDBTEST> select pdb_id, pdb_name, dbid, status, creation_scn, con_id from CDB_PDBS;
2.
3. PDB_ID PDB_NAME DBID STATUS CREATION_SCN CON_ID
4. ---------- ---------- ---------- ------------- ------------ ----------
5. 2 PDB$SEED 4063610283 NORMAL 217 1
6. 3 PDBTEST1 3064465721 NORMAL 1547881 1
7. 4 PDBTEST2 2395404598 NORMAL 1548944 1
8. 5 PDBTEST3 2434165039 NORMAL 1550036 1
9. 6 PDB003 1448206714 NORMAL 2744910 1
10. 7 ORCL 1350603571 NORMAL 3226095 1
That's all.

Más contenido relacionado

Destacado

Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...Alex Zaballa
 
Oracle database 12c sql worshop 2 activity guide
Oracle database 12c sql worshop 2 activity guideOracle database 12c sql worshop 2 activity guide
Oracle database 12c sql worshop 2 activity guideOtto Paiz
 
Oracle database 12c sql worshop 1 student guide vol 2
Oracle database 12c sql worshop 1 student guide vol 2Oracle database 12c sql worshop 1 student guide vol 2
Oracle database 12c sql worshop 1 student guide vol 2Otto Paiz
 
What You Should Know About WebLogic Server 12c (12.2.1.2) #oow2015 #otntour2...
What You Should Know About WebLogic Server 12c (12.2.1.2)  #oow2015 #otntour2...What You Should Know About WebLogic Server 12c (12.2.1.2)  #oow2015 #otntour2...
What You Should Know About WebLogic Server 12c (12.2.1.2) #oow2015 #otntour2...Frank Munz
 
Oracle SQL Developer Tips & Tricks
Oracle SQL Developer Tips & TricksOracle SQL Developer Tips & Tricks
Oracle SQL Developer Tips & TricksJeff Smith
 
Oracle database 12c sql worshop 2 student guide vol 1
Oracle database 12c sql worshop 2 student guide vol 1Oracle database 12c sql worshop 2 student guide vol 1
Oracle database 12c sql worshop 2 student guide vol 1Otto Paiz
 
SQL Monitoring in Oracle Database 12c
SQL Monitoring in Oracle Database 12cSQL Monitoring in Oracle Database 12c
SQL Monitoring in Oracle Database 12cTanel Poder
 
Oracle database 12c sql worshop 2 student guide vol 2
Oracle database 12c sql worshop 2 student guide vol 2Oracle database 12c sql worshop 2 student guide vol 2
Oracle database 12c sql worshop 2 student guide vol 2Otto Paiz
 
Oracle 12c RAC On your laptop Step by Step Implementation Guide 1.0
Oracle 12c RAC On your laptop Step by Step Implementation Guide 1.0Oracle 12c RAC On your laptop Step by Step Implementation Guide 1.0
Oracle 12c RAC On your laptop Step by Step Implementation Guide 1.0Yury Velikanov
 
How to Use Oracle RAC in a Cloud? - A Support Question
How to Use Oracle RAC in a Cloud? - A Support QuestionHow to Use Oracle RAC in a Cloud? - A Support Question
How to Use Oracle RAC in a Cloud? - A Support QuestionMarkus Michalewicz
 
Best New Features of Oracle Database 12c
Best New Features of Oracle Database 12cBest New Features of Oracle Database 12c
Best New Features of Oracle Database 12cPini Dibask
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c  - New Features for Developers and DBAsOracle Database 12c  - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsAlex Zaballa
 

Destacado (12)

Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
 
Oracle database 12c sql worshop 2 activity guide
Oracle database 12c sql worshop 2 activity guideOracle database 12c sql worshop 2 activity guide
Oracle database 12c sql worshop 2 activity guide
 
Oracle database 12c sql worshop 1 student guide vol 2
Oracle database 12c sql worshop 1 student guide vol 2Oracle database 12c sql worshop 1 student guide vol 2
Oracle database 12c sql worshop 1 student guide vol 2
 
What You Should Know About WebLogic Server 12c (12.2.1.2) #oow2015 #otntour2...
What You Should Know About WebLogic Server 12c (12.2.1.2)  #oow2015 #otntour2...What You Should Know About WebLogic Server 12c (12.2.1.2)  #oow2015 #otntour2...
What You Should Know About WebLogic Server 12c (12.2.1.2) #oow2015 #otntour2...
 
Oracle SQL Developer Tips & Tricks
Oracle SQL Developer Tips & TricksOracle SQL Developer Tips & Tricks
Oracle SQL Developer Tips & Tricks
 
Oracle database 12c sql worshop 2 student guide vol 1
Oracle database 12c sql worshop 2 student guide vol 1Oracle database 12c sql worshop 2 student guide vol 1
Oracle database 12c sql worshop 2 student guide vol 1
 
SQL Monitoring in Oracle Database 12c
SQL Monitoring in Oracle Database 12cSQL Monitoring in Oracle Database 12c
SQL Monitoring in Oracle Database 12c
 
Oracle database 12c sql worshop 2 student guide vol 2
Oracle database 12c sql worshop 2 student guide vol 2Oracle database 12c sql worshop 2 student guide vol 2
Oracle database 12c sql worshop 2 student guide vol 2
 
Oracle 12c RAC On your laptop Step by Step Implementation Guide 1.0
Oracle 12c RAC On your laptop Step by Step Implementation Guide 1.0Oracle 12c RAC On your laptop Step by Step Implementation Guide 1.0
Oracle 12c RAC On your laptop Step by Step Implementation Guide 1.0
 
How to Use Oracle RAC in a Cloud? - A Support Question
How to Use Oracle RAC in a Cloud? - A Support QuestionHow to Use Oracle RAC in a Cloud? - A Support Question
How to Use Oracle RAC in a Cloud? - A Support Question
 
Best New Features of Oracle Database 12c
Best New Features of Oracle Database 12cBest New Features of Oracle Database 12c
Best New Features of Oracle Database 12c
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c  - New Features for Developers and DBAsOracle Database 12c  - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
 

Último

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 

Último (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

Oracle Database 12c: How to create a pdb from a non-cdb using dbms_pdb package

  • 1. Articles from Database administrator workshop How to create a PDB from a Non-CDB using DBMS_PDB package To test this scenario I have recently created using DBCA a non container database named ORCL. CDB001 and CDBTEST are instead two container databases. view plainprint? 1. [oracle@vsi08devpom ~]$ ps -ef|grep smon 2. oracle 4081 1 0 Jul15 ? 00:01:30 ora_smon_CDB001 3. oracle 11394 1 0 10:20 ? 00:00:00 ora_smon_ORCL 4. oracle 12586 9609 0 10:46 pts/0 00:00:00 grep smon 5. oracle 16455 1 0 Jul17 ? 00:01:34 ora_smon_CDBTEST I want to consolidate this database plugging it into a container database. In this scenario I'm going to use the DBMS_PDB package to create the XML file with the metadata of ORCL database. Before using the DBMS_PDB.DESCRIBE procedure, the ORCL database needs to be in READ ONLY mode. view plainprint? 1. [oracle@vsi08devpom ~]$ export ORACLE_SID=ORCL 2. [oracle@vsi08devpom ~]$ sqlplus / as sysdba 3. 4. SQL*Plus: Release 12.1.0.1.0 Production on Wed Aug 7 10:47:29 2013 5. 6. Copyright (c) 1982, 2013, Oracle. All rights reserved. 7. 8. Connected to: 9. Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production 10. With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options 11. 12. SQL@ORCL> show con_name; 13. 14. CON_NAME 15. ------------------------------ 16. Non Consolidated 17. SQL@ORCL> select name, open_mode from V$DATABASE; 18. 19. NAME OPEN_MODE 20. --------- -------------------- 21. ORCL READ WRITE 22. 23. SQL@ORCL> shutdown immediate; 24. Database closed. 25. Database dismounted. 26. ORACLE instance shut down. 27. 28. SQL@ORCL> startup mount; 29. ORACLE instance started. 30. 31. Total System Global Area 471830528 bytes 32. Fixed Size 2289688 bytes 33. Variable Size 264245224 bytes 34. Database Buffers 197132288 bytes 35. Redo Buffers 8163328 bytes 36. Database mounted. 37. SQL@ORCL> alter database open read only; 38. 39. Database altered. view plainprint? 1. SQL@ORCL> begin 2. 2 dbms_pdb.describe( pdb_descr_file => '/opt/app/oracle/oradata/orcl.xml'); 3. 3 end; 4. 4 / 5. 6. PL/SQL procedure successfully completed. 7. 8. SQL@ORCL> host ls /opt/app/oracle/oradata/orcl* 9. /opt/app/oracle/oradata/orcl.xml 10. 11. SQL@ORCL> shutdown immediate; 12. Database closed. 13. Database dismounted. 14. ORACLE instance shut down. 15. SQL@ORCL> exit Now connect to the container database. In my case I want to plug ORCL database into the CDBTEST container. It currently contains 4 pluggable databases. view plainprint? 1. [oracle@vsi08devpom ~]$ export ORACLE_SID=CDBTEST 2. [oracle@vsi08devpom ~]$ sqlplus / as sysdba 3. 4. SQL*Plus: Release 12.1.0.1.0 Production on Wed Aug 7 11:07:12 2013 5. 6. Copyright (c) 1982, 2013, Oracle. All rights reserved. 7. 8. Connected to: 9. Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production 10. With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options 11. 12. SQL@CDBTEST> show con_name; 13. 14. CON_NAME 15. ------------------------------ 16. CDB$ROOT 17. 18. SQL@CDBTEST> select name, open_mode from V$PDBS; 19. 20. NAME OPEN_MODE 21. ------------------------------ ---------- 22. PDB$SEED READ ONLY 23. PDBTEST1 READ WRITE
  • 2. 24. PDBTEST2 READ WRITE 25. PDBTEST3 READ WRITE 26. PDB003 READ ONLY Here is the situation of the directories for the CDBTEST container database: view plainprint? 1. [oracle@vsi08devpom ~]$ cd /opt/app/oracle/oradata/CDBTEST/ 2. [oracle@vsi08devpom CDBTEST]$ ll 3. total 3459784 4. -rw-r----- 1 oracle oinstall 17973248 Aug 7 11:13 control01.ctl 5. drwxr-x--- 2 oracle oinstall 4096 Aug 1 14:54 PDB003 6. drwxr-x--- 2 oracle oinstall 4096 Jul 17 11:25 pdbseed 7. drwxr-x--- 2 oracle oinstall 4096 Jul 17 13:16 PDBTEST1 8. drwxr-x--- 2 oracle oinstall 4096 Jul 17 13:17 PDBTEST2 9. drwxr-x--- 2 oracle oinstall 4096 Jul 17 13:18 PDBTEST3 10. -rw-r----- 1 oracle oinstall 52429312 Aug 7 11:12 redo01.log 11. -rw-r----- 1 oracle oinstall 52429312 Aug 7 00:16 redo02.log 12. -rw-r----- 1 oracle oinstall 52429312 Aug 7 06:00 redo03.log 13. -rw-r----- 1 oracle oinstall 1310728192 Aug 7 11:12 sysaux01.dbf 14. -rw-r----- 1 oracle oinstall 828383232 Aug 7 11:12 system01.dbf 15. -rw-r----- 1 oracle oinstall 63971328 Aug 7 11:01 temp01.dbf 16. -rw-r----- 1 oracle oinstall 1205870592 Aug 7 11:12 undotbs01.dbf 17. -rw-r----- 1 oracle oinstall 5251072 Aug 7 06:05 users01.dbf Now you can plug the ORCL database into the CDBTEST container database using the usual syntax (have a look at this post) view plainprint? 1. SQL@CDBTEST> create pluggable database ORCL using '/opt/app/oracle/oradata/orcl.xml' copy file_name_convert=('/opt/app/oracle/oradata/ORCL','/opt/app/oracle/oradata/CDBTEST/ORCL'); 2. 3. Pluggable database created. The Oracle software copies under the directory /opt/app/oracle/oradata/CDBTEST/ORCL all the datafiles coming from /opt/app/oracle/oradata/ORCL location. view plainprint? 1. [oracle@vsi08devpom CDBTEST]$ ll 2. total 3459788 3. -rw-r----- 1 oracle oinstall 17973248 Aug 7 12:10 control01.ctl 4. drwxr-x--- 2 oracle oinstall 4096 Aug 7 11:49 ORCL 5. drwxr-x--- 2 oracle oinstall 4096 Aug 1 14:54 PDB003 6. drwxr-x--- 2 oracle oinstall 4096 Jul 17 11:25 pdbseed 7. drwxr-x--- 2 oracle oinstall 4096 Jul 17 13:16 PDBTEST1 8. drwxr-x--- 2 oracle oinstall 4096 Jul 17 13:17 PDBTEST2 9. drwxr-x--- 2 oracle oinstall 4096 Jul 17 13:18 PDBTEST3 10. -rw-r----- 1 oracle oinstall 52429312 Aug 7 12:10 redo01.log 11. -rw-r----- 1 oracle oinstall 52429312 Aug 7 00:16 redo02.log 12. -rw-r----- 1 oracle oinstall 52429312 Aug 7 06:00 redo03.log 13. -rw-r----- 1 oracle oinstall 1310728192 Aug 7 12:10 sysaux01.dbf 14. -rw-r----- 1 oracle oinstall 828383232 Aug 7 12:07 system01.dbf 15. -rw-r----- 1 oracle oinstall 63971328 Aug 7 12:03 temp01.dbf 16. -rw-r----- 1 oracle oinstall 1205870592 Aug 7 12:10 undotbs01.dbf 17. -rw-r----- 1 oracle oinstall 5251072 Aug 7 06:05 users01.dbf A new pluggable database is created with a NEW status view plainprint? 1. SQL@CDBTEST> select pdb_id, pdb_name, dbid, status, creation_scn, con_id from CDB_PDBS; 2. 3. PDB_ID PDB_NAME DBID STATUS CREATION_SCN CON_ID 4. ---------- ---------- ---------- ------------- ------------ ---------- 5. 2 PDB$SEED 4063610283 NORMAL 217 1 6. 3 PDBTEST1 3064465721 NORMAL 1547881 1 7. 4 PDBTEST2 2395404598 NORMAL 1548944 1 8. 5 PDBTEST3 2434165039 NORMAL 1550036 1 9. 6 PDB003 1448206714 NORMAL 2744910 1 10. 7 ORCL 1350603571 NEW 3226095 1 It's still not the time to open the new PDB. You need first to execute, while connected to the new pluggable database, the script $ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql: view plainprint? 1. [oracle@vsi08devpom CDBTEST]$ ll /opt/app/oracle/product/12.1.0/db_1/rdbms/admin/noncdb_to_pdb.sql 2. -rw-r--r-- 1 oracle oinstall 19191 Apr 15 22:27 /opt/app/oracle/product/12.1.0/db_1/rdbms/admin/noncdb_to_pdb.sql 3. 4. SQL@CDBTEST> alter session set container=ORCL; 5. 6. Session altered. 7. 8. SQL@CDBTEST> @/opt/app/oracle/product/12.1.0/db_1/rdbms/admin/noncdb_to_pdb.sql 9. SQL@CDBTEST> SET SERVEROUTPUT ON 10. SQL@CDBTEST> SET FEEDBACK 1 11. SQL@CDBTEST> SET NUMWIDTH 10 12. ... 13. ... 14. ... 15. SQL@CDBTEST> -- leave the PDB in the same state it was when we started 16. SQL@CDBTEST> BEGIN 17. 2 execute immediate '&open_sql &restricted_state'; 18. 3 EXCEPTION 19. 4 WHEN OTHERS THEN 20. 5 BEGIN 21. 6 IF (sqlcode <> -900) THEN 22. 7 RAISE; 23. 8 END IF; 24. 9 END; 25. 10 END; 26. 11 / 27. 28. PL/SQL procedure successfully completed. 29. 30. SQL@CDBTEST> 31. SQL@CDBTEST> WHENEVER SQLERROR CONTINUE; 32. SQL@CDBTEST> Now you can open the new ORCL pluggable database. view plainprint? 1. SQL@CDBTEST> show con_name; 2.
  • 3. 3. CON_NAME 4. ------------------------------ 5. ORCL 6. SQL@CDBTEST> alter database open; 7. 8. Database altered. The database is so available and ready to be used. view plainprint? 1. SQL@CDBTEST> select pdb_id, pdb_name, dbid, status, creation_scn, con_id from CDB_PDBS; 2. 3. PDB_ID PDB_NAME DBID STATUS CREATION_SCN CON_ID 4. ---------- ---------- ---------- ------------- ------------ ---------- 5. 2 PDB$SEED 4063610283 NORMAL 217 1 6. 3 PDBTEST1 3064465721 NORMAL 1547881 1 7. 4 PDBTEST2 2395404598 NORMAL 1548944 1 8. 5 PDBTEST3 2434165039 NORMAL 1550036 1 9. 6 PDB003 1448206714 NORMAL 2744910 1 10. 7 ORCL 1350603571 NORMAL 3226095 1 That's all.