SlideShare une entreprise Scribd logo
1  sur  4
Télécharger pour lire hors ligne
Articles from Database administrator
workshop
How to create a pluggable database by cloning an
existing local PDB
Using the CREATE PLUGGABLE DATABASE ... FROM command you can clone
an existing pluggable database (the source pdb) to create a new pdb (the clone
pdb).
The source pdb could be in the current local container or it can be located in a
remote container (in a next post): during a clone of a remote pdb you need to use a
database link referencing the remote container in the FROM clause.
Let's start cloning a local pluggable database. Be sure the current container is the
root
view plainprint?
1. SQL> show con_name;
2.
3. CON_NAME
4. ------------------------------
5. CDB$ROOT
Here are my current pluggable databases and I want to clone PDB001 which
contains the user MARCOV and the table T1 (with 100 rows)
view plainprint?
1. SQL> select name, open_mode from V$PDBS;
2.
3. NAME OPEN_MODE
4. ------------------------------ ----------
5. PDB$SEED READ ONLY
6. PDB001 READ WRITE
7. PDB002 READ WRITE
8.
9. SQL> alter session set container=PDB001;
10.
11. Session altered.
12.
13. SQL> create user marcov identified by marcov quota unlimited on users;
14.
15. User created.
16.
17. SQL> grant create session to marcov;
18.
19. Grant succeeded.
20.
21. SQL> grant create table to marcov;
22.
23. Grant succeeded.
24.
25. SQL> connect marcov/marcov@PDB001
26. Connected.
27. SQL> show user
28. USER is "MARCOV"
29. SQL> show con_name
30.
31. CON_NAME
32. ------------------------------
33. PDB001
34.
35. SQL> create table T1 (a number);
36.
37. Table created.
38.
39. SQL> create table T1 (a number);
40.
41. Table created.
42.
43. SQL> insert into T1 select level from dual connect by level < 101;
44.
45. 100 rows created.
46.
47. SQL> commit;
48.
49. Commit complete.
50.
51. SQL> connect / as sysdba
52. Connected.
53. SQL> show user
54. USER is "SYS"
55. SQL> show con_name
56.
57. CON_NAME
58. ------------------------------
59. CDB$ROOT
Here is the content of my tnsnames.ora file
view plainprint?
1. CDB001 =
2. (DESCRIPTION =
3. (ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.2.15)(PORT = 1521))
4. (CONNECT_DATA =
5. (SERVER = DEDICATED)
6. (SERVICE_NAME = CDB001)
7. )
8. )
9.
10. PDB001 =
11. (DESCRIPTION =
12. (ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.2.15)(PORT = 1521))
13. (CONNECT_DATA =
14. (SERVER = DEDICATED)
15. (SERVICE_NAME = PDB001)
16. )
17. )
To clone the source pluggable database PDB001 I need to open it in READ ONLY
mode
view plainprint?
1. SQL> select name, open_mode from v$pdbs;
2.
3. NAME OPEN_MODE
4. ------------------------------ ----------
5. PDB$SEED READ ONLY
6. PDB001 READ WRITE
7. PDB002 READ WRITE
8.
9. SQL> alter pluggable database PDB001 open read only force;
10.
11. Pluggable database altered.
On my file system I have the following directories and files.
view plainprint?
1. [oracle@localhost CDB001]$ pwd
2. /app/oracle/oradata/CDB001
3. [oracle@localhost CDB001]$ ll
4. total 2163224
5. -rw-r-----. 1 oracle oinstall 17973248 Jul 30 13:12 control01.ctl
6. drwxr-x---. 2 oracle oinstall 4096 Jul 20 15:29 PDB001
7. drwxr-x---. 2 oracle oinstall 4096 Jul 20 16:22 PDB002
8. drwxr-x---. 2 oracle oinstall 4096 Jul 15 22:07 pdbseed
9. -rw-r-----. 1 oracle oinstall 52429312 Jul 30 13:12 redo01.log
10. -rw-r-----. 1 oracle oinstall 52429312 Jul 29 22:06 redo02.log
11. -rw-r-----. 1 oracle oinstall 52429312 Jul 30 02:32 redo03.log
12. -rw-r-----. 1 oracle oinstall 817897472 Jul 30 13:11 sysaux01.dbf
13. -rw-r-----. 1 oracle oinstall 817897472 Jul 30 13:06 system01.dbf
14. -rw-r-----. 1 oracle oinstall 76554240 Jul 30 13:11 temp01.dbf
15. -rw-r-----. 1 oracle oinstall 325066752 Jul 30 13:10 undotbs01.dbf
16. -rw-r-----. 1 oracle oinstall 5251072 Jul 30 02:37 users01.dbf
Here is the content of PDB001 directory.
view plainprint?
1. [oracle@localhost CDB001]$ ll PDB001/
2. total 922516
3. -rw-r-----. 1 oracle oinstall 5251072 Jul 30 13:08 PDB001_users01.dbf
4. -rw-r-----. 1 oracle oinstall 665853952 Jul 30 13:08 sysaux01.dbf
5. -rw-r-----. 1 oracle oinstall 272637952 Jul 30 13:08 system01.dbf
6. -rw-r-----. 1 oracle oinstall 20979712 Jul 21 17:51 temp01.dbf
I'm going to create a new pluggable database called PDB003, cloning PDB001. The
command to clone a pluggable database locally is the following:
view plainprint?
1. SQL> create pluggable database PDB003 from PDB001 file_name_convert=('/app/oracle/oradata/CDB001/PDB001','/app/oracle/oradata/CDB001/PDB003');
2.
3. Pluggable database created.
New files and directories are created. Note also the same name of the datafile
PDB001_users01.dbf used as default tablespace for PDB003.
view plainprint?
1. [oracle@localhost CDB001]$ ll
2. total 2163228
3. -rw-r-----. 1 oracle oinstall 17973248 Jul 30 13:19 control01.ctl
4. drwxr-x---. 2 oracle oinstall 4096 Jul 20 15:29 PDB001
5. drwxr-x---. 2 oracle oinstall 4096 Jul 20 16:22 PDB002
6. drwxr-x---. 2 oracle oinstall 4096 Jul 30 13:17 PDB003
7. drwxr-x---. 2 oracle oinstall 4096 Jul 15 22:07 pdbseed
8. -rw-r-----. 1 oracle oinstall 52429312 Jul 30 13:18 redo01.log
9. -rw-r-----. 1 oracle oinstall 52429312 Jul 29 22:06 redo02.log
10. -rw-r-----. 1 oracle oinstall 52429312 Jul 30 02:32 redo03.log
11. -rw-r-----. 1 oracle oinstall 817897472 Jul 30 13:18 sysaux01.dbf
12. -rw-r-----. 1 oracle oinstall 817897472 Jul 30 13:17 system01.dbf
13. -rw-r-----. 1 oracle oinstall 76554240 Jul 30 13:18 temp01.dbf
14. -rw-r-----. 1 oracle oinstall 325066752 Jul 30 13:16 undotbs01.dbf
15. -rw-r-----. 1 oracle oinstall 5251072 Jul 30 02:37 users01.dbf
16. [oracle@localhost CDB001]$ ll PDB003
17. total 921688
18. -rw-r-----. 1 oracle oinstall 5251072 Jul 30 13:18 PDB001_users01.dbf
19. -rw-r-----. 1 oracle oinstall 665853952 Jul 30 13:18 sysaux01.dbf
20. -rw-r-----. 1 oracle oinstall 272637952 Jul 30 13:18 system01.dbf
21. -rw-r-----. 1 oracle oinstall 20979712 Jul 30 13:17 temp01.dbf
After the command is sucessfully completed the status and the open mode of the
new pluggable database are NEW and MOUNTED.
view plainprint?
1. SQL> select PDB_NAME, STATUS from CDB_PDBS;
2.
3. PDB_NAME STATUS
4. ---------- -------------
5. PDB$SEED NORMAL
6. PDB001 NORMAL
7. PDB002 NORMAL
8. PDB003 NEW
9.
10. SQL> select name, open_mode from V$PDBS;
11.
12. NAME OPEN_MODE
13. ------------------------------ ----------
14. PDB$SEED READ ONLY
15. PDB001 READ ONLY
16. PDB002 READ WRITE
17. PDB003 MOUNTED
A new service is created too.
view plainprint?
1. SQL> select name, pdb from V$SERVICES order by creation_date;
2.
3. NAME PDB
4. -------------------- ------------------------------
5. CDB001XDB CDB$ROOT
6. SYS$BACKGROUND CDB$ROOT
7. CDB001 CDB$ROOT
8. SYS$USERS CDB$ROOT
9. pdb001 PDB001
10. pdb002 PDB002
11. pdb003 PDB003
You can now open both pluggable databases with one simply command (have a
look at this post for more information about the syntax and examples)
view plainprint?
1. SQL> alter pluggable database PDB001,PDB003 open READ WRITE FORCE;
2.
3. Pluggable database altered.
4.
5. SQL> select name, open_mode from V$PDBS;
6.
7. NAME OPEN_MODE
8. -------------------- ----------
9. PDB$SEED READ ONLY
10. PDB001 READ WRITE
11. PDB002 READ WRITE
12. PDB003 READ WRITE
13.
14. SQL> select PDB_NAME, STATUS from CDB_PDBS;
15.
16. PDB_NAME STATUS
17. ---------- -------------
18. PDB$SEED NORMAL
19. PDB001 NORMAL
20. PDB002 NORMAL
21. PDB003 NORMAL
Add the following entry on the tnsnames.ora file.
view plainprint?
1. PDB003 =
2. (DESCRIPTION =
3. (ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.2.15)(PORT = 1521))
4. (CONNECT_DATA =
5. (SERVER = DEDICATED)
6. (SERVICE_NAME = PDB003)
7. )
8. )
Let's see my data on PDB003 and on PDB001
view plainprint?
1. SQL> connect marcov/marcov@PDB003
2. Connected.
3. SQL> show con_name
4.
5. CON_NAME
6. ------------------------------
7. PDB003
8. SQL> select count(*) from marcov.T1;
9.
10. COUNT(*)
11. ----------
12. 100
13.
14. SQL> connect marcov/marcov@PDB001
15. Connected.
16. SQL> show con_name
17.
18. CON_NAME
19. ------------------------------
20. PDB001
21. SQL> select count(*) from marcov.T1;
22.
23. COUNT(*)
24. ----------
25. 100
It is not possible to create a new pdb cloning a local or a remote seed: to create a
new pdb from the seed you have to follow this post. If you try to clone from the seed
template you will receive the ORA-65000 error, described below:
view plainprint?
1. SQL> create pluggable database PDB004 from PDB$SEED file_name_convert=('/app/oracle/oradata/CDB001/pdbseed','/app/oracle/oradata/CDB001/PDB004');
2. create pluggable database PDB004 from PDB$SEED file_name_convert=('/app/oracle/oradata/CDB001/pdbseed','/app/oracle/oradata/CDB001/PDB004')
3. *
4. ERROR at line 1:
5. ORA-65000: missing or invalid pluggable database name
6.
7. [oracle@localhost pdbseed]$ oerr ora 65000
8. 65000, 00000, "missing or invalid pluggable database name"
9. // *Cause: A valid pluggable database name was not present where required
10. // by the syntax of a CREATE PLUGGABLE DATABASE, ALTER PLUGGABLE
11. // DATABASE or DROP PLUGGABLE DATABASE statement.
12. // *Action: Reissue the statement with a valid pluggable database name.
That's all.

Contenu connexe

Tendances

Come configurare Liferay 6.0 per Oracle
Come configurare Liferay 6.0 per OracleCome configurare Liferay 6.0 per Oracle
Come configurare Liferay 6.0 per Oracle
Antonio Musarra
 
Flashback (Practical Test)
Flashback (Practical Test)Flashback (Practical Test)
Flashback (Practical Test)
Anar Godjaev
 
Pontos para criar_instancia_data guard_11g
Pontos para criar_instancia_data guard_11gPontos para criar_instancia_data guard_11g
Pontos para criar_instancia_data guard_11g
Leandro Santos
 
Schema replication using oracle golden gate 12c
Schema replication using oracle golden gate 12cSchema replication using oracle golden gate 12c
Schema replication using oracle golden gate 12c
uzzal basak
 
FIXING BLOCK CORRUPTION (RMAN) on 11G
FIXING BLOCK CORRUPTION (RMAN) on 11GFIXING BLOCK CORRUPTION (RMAN) on 11G
FIXING BLOCK CORRUPTION (RMAN) on 11G
N/A
 
Basic - Oracle Edition Based Redefinition Presentation
Basic - Oracle Edition Based Redefinition PresentationBasic - Oracle Edition Based Redefinition Presentation
Basic - Oracle Edition Based Redefinition Presentation
N/A
 
UKOUG, Oracle Transaction Locks
UKOUG, Oracle Transaction LocksUKOUG, Oracle Transaction Locks
UKOUG, Oracle Transaction Locks
Kyle Hailey
 

Tendances (20)

Postgresql 12 streaming replication hol
Postgresql 12 streaming replication holPostgresql 12 streaming replication hol
Postgresql 12 streaming replication hol
 
Come configurare Liferay 6.0 per Oracle
Come configurare Liferay 6.0 per OracleCome configurare Liferay 6.0 per Oracle
Come configurare Liferay 6.0 per Oracle
 
OakTable World Sep14 clonedb
OakTable World Sep14 clonedb OakTable World Sep14 clonedb
OakTable World Sep14 clonedb
 
Flashback (Practical Test)
Flashback (Practical Test)Flashback (Practical Test)
Flashback (Practical Test)
 
Moving 12c database from NON-ASM to ASM
Moving 12c database from NON-ASM to ASMMoving 12c database from NON-ASM to ASM
Moving 12c database from NON-ASM to ASM
 
Pontos para criar_instancia_data guard_11g
Pontos para criar_instancia_data guard_11gPontos para criar_instancia_data guard_11g
Pontos para criar_instancia_data guard_11g
 
MySQLinsanity
MySQLinsanityMySQLinsanity
MySQLinsanity
 
Schema replication using oracle golden gate 12c
Schema replication using oracle golden gate 12cSchema replication using oracle golden gate 12c
Schema replication using oracle golden gate 12c
 
Postgres 12 Cluster Database operations.
Postgres 12 Cluster Database operations.Postgres 12 Cluster Database operations.
Postgres 12 Cluster Database operations.
 
FIXING BLOCK CORRUPTION (RMAN) on 11G
FIXING BLOCK CORRUPTION (RMAN) on 11GFIXING BLOCK CORRUPTION (RMAN) on 11G
FIXING BLOCK CORRUPTION (RMAN) on 11G
 
Basic - Oracle Edition Based Redefinition Presentation
Basic - Oracle Edition Based Redefinition PresentationBasic - Oracle Edition Based Redefinition Presentation
Basic - Oracle Edition Based Redefinition Presentation
 
My sql fabric ha and sharding solutions
My sql fabric ha and sharding solutionsMy sql fabric ha and sharding solutions
My sql fabric ha and sharding solutions
 
제 8회 엑셈 수요 세미나 자료 연구컨텐츠팀
제 8회 엑셈 수요 세미나 자료 연구컨텐츠팀제 8회 엑셈 수요 세미나 자료 연구컨텐츠팀
제 8회 엑셈 수요 세미나 자료 연구컨텐츠팀
 
PGDay.Amsterdam 2018 - Stefan Fercot - Save your data with pgBackRest
PGDay.Amsterdam 2018 - Stefan Fercot - Save your data with pgBackRestPGDay.Amsterdam 2018 - Stefan Fercot - Save your data with pgBackRest
PGDay.Amsterdam 2018 - Stefan Fercot - Save your data with pgBackRest
 
Multiple instances on linux
Multiple instances on linuxMultiple instances on linux
Multiple instances on linux
 
Rac nonrac clone
Rac nonrac cloneRac nonrac clone
Rac nonrac clone
 
제 6회 엑셈 수요 세미나 자료 연구컨텐츠팀
제 6회 엑셈 수요 세미나 자료 연구컨텐츠팀제 6회 엑셈 수요 세미나 자료 연구컨텐츠팀
제 6회 엑셈 수요 세미나 자료 연구컨텐츠팀
 
Backups
BackupsBackups
Backups
 
Tibero sql execution plan guide en
Tibero sql execution plan guide enTibero sql execution plan guide en
Tibero sql execution plan guide en
 
UKOUG, Oracle Transaction Locks
UKOUG, Oracle Transaction LocksUKOUG, Oracle Transaction Locks
UKOUG, Oracle Transaction Locks
 

Similaire à How to create a pluggable database by cloning an existing local pdb

Oracle12c Pluggable Database Hands On - TROUG 2014
Oracle12c Pluggable Database Hands On - TROUG 2014Oracle12c Pluggable Database Hands On - TROUG 2014
Oracle12c Pluggable Database Hands On - TROUG 2014
Özgür Umut Vurgun
 
oracle cloud with 2 nodes processing
oracle cloud with 2 nodes processingoracle cloud with 2 nodes processing
oracle cloud with 2 nodes processing
mahdi ahmadi
 
11thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp0111thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp01
Karam Abuataya
 

Similaire à How to create a pluggable database by cloning an existing local pdb (20)

Oracle Multitenant Database 2.0 - Improvements in Oracle Database 12c Release 2
Oracle Multitenant Database 2.0 - Improvements in Oracle Database 12c Release 2Oracle Multitenant Database 2.0 - Improvements in Oracle Database 12c Release 2
Oracle Multitenant Database 2.0 - Improvements in Oracle Database 12c Release 2
 
Oracle Multitenant Database 2.0 - Improvements in Oracle Database 12c Release 2
Oracle Multitenant Database 2.0 - Improvements in Oracle Database 12c Release 2Oracle Multitenant Database 2.0 - Improvements in Oracle Database 12c Release 2
Oracle Multitenant Database 2.0 - Improvements in Oracle Database 12c Release 2
 
Oracle12c Pluggable Database Hands On - TROUG 2014
Oracle12c Pluggable Database Hands On - TROUG 2014Oracle12c Pluggable Database Hands On - TROUG 2014
Oracle12c Pluggable Database Hands On - TROUG 2014
 
Pluggable database tutorial
Pluggable database tutorialPluggable database tutorial
Pluggable database tutorial
 
Drizzle to MySQL, Stress Free Migration
Drizzle to MySQL, Stress Free MigrationDrizzle to MySQL, Stress Free Migration
Drizzle to MySQL, Stress Free Migration
 
br_test_lossof-datafile_10g.doc
br_test_lossof-datafile_10g.docbr_test_lossof-datafile_10g.doc
br_test_lossof-datafile_10g.doc
 
Oracle data guard configuration in 12c
Oracle data guard configuration in 12cOracle data guard configuration in 12c
Oracle data guard configuration in 12c
 
oracle cloud with 2 nodes processing
oracle cloud with 2 nodes processingoracle cloud with 2 nodes processing
oracle cloud with 2 nodes processing
 
Database decommission process
Database decommission processDatabase decommission process
Database decommission process
 
Pluggable database tutorial 2
Pluggable database tutorial 2Pluggable database tutorial 2
Pluggable database tutorial 2
 
Percona xtra db cluster(pxc) non blocking operations, what you need to know t...
Percona xtra db cluster(pxc) non blocking operations, what you need to know t...Percona xtra db cluster(pxc) non blocking operations, what you need to know t...
Percona xtra db cluster(pxc) non blocking operations, what you need to know t...
 
Install and upgrade Oracle grid infrastructure 12.1.0.2
Install and upgrade Oracle grid infrastructure 12.1.0.2Install and upgrade Oracle grid infrastructure 12.1.0.2
Install and upgrade Oracle grid infrastructure 12.1.0.2
 
Physical_Standby_Database_R12.2.4
Physical_Standby_Database_R12.2.4Physical_Standby_Database_R12.2.4
Physical_Standby_Database_R12.2.4
 
Quickly Locate Poorly Performing DB2 for z/OS Batch SQL
Quickly Locate Poorly Performing DB2 for z/OS Batch SQL Quickly Locate Poorly Performing DB2 for z/OS Batch SQL
Quickly Locate Poorly Performing DB2 for z/OS Batch SQL
 
Mod03 linking and accelerating
Mod03 linking and acceleratingMod03 linking and accelerating
Mod03 linking and accelerating
 
Setup oracle golden gate 11g replication
Setup oracle golden gate 11g replicationSetup oracle golden gate 11g replication
Setup oracle golden gate 11g replication
 
New Features for Multitenant in Oracle Database 21c
New Features for Multitenant in Oracle Database 21cNew Features for Multitenant in Oracle Database 21c
New Features for Multitenant in Oracle Database 21c
 
11thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp0111thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp01
 
11 Things About11g
11 Things About11g11 Things About11g
11 Things About11g
 
OpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developersOpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developers
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Dernier (20)

Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
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
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
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...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 

How to create a pluggable database by cloning an existing local pdb

  • 1. Articles from Database administrator workshop How to create a pluggable database by cloning an existing local PDB Using the CREATE PLUGGABLE DATABASE ... FROM command you can clone an existing pluggable database (the source pdb) to create a new pdb (the clone pdb). The source pdb could be in the current local container or it can be located in a remote container (in a next post): during a clone of a remote pdb you need to use a database link referencing the remote container in the FROM clause. Let's start cloning a local pluggable database. Be sure the current container is the root view plainprint? 1. SQL> show con_name; 2. 3. CON_NAME 4. ------------------------------ 5. CDB$ROOT Here are my current pluggable databases and I want to clone PDB001 which contains the user MARCOV and the table T1 (with 100 rows) view plainprint? 1. SQL> select name, open_mode from V$PDBS; 2. 3. NAME OPEN_MODE 4. ------------------------------ ---------- 5. PDB$SEED READ ONLY 6. PDB001 READ WRITE 7. PDB002 READ WRITE 8. 9. SQL> alter session set container=PDB001; 10. 11. Session altered. 12. 13. SQL> create user marcov identified by marcov quota unlimited on users; 14. 15. User created. 16. 17. SQL> grant create session to marcov; 18. 19. Grant succeeded. 20. 21. SQL> grant create table to marcov; 22. 23. Grant succeeded. 24. 25. SQL> connect marcov/marcov@PDB001 26. Connected. 27. SQL> show user 28. USER is "MARCOV" 29. SQL> show con_name 30. 31. CON_NAME 32. ------------------------------ 33. PDB001 34. 35. SQL> create table T1 (a number); 36. 37. Table created. 38. 39. SQL> create table T1 (a number); 40. 41. Table created. 42. 43. SQL> insert into T1 select level from dual connect by level < 101; 44. 45. 100 rows created. 46. 47. SQL> commit; 48. 49. Commit complete. 50. 51. SQL> connect / as sysdba 52. Connected. 53. SQL> show user 54. USER is "SYS" 55. SQL> show con_name 56. 57. CON_NAME 58. ------------------------------ 59. CDB$ROOT Here is the content of my tnsnames.ora file view plainprint? 1. CDB001 =
  • 2. 2. (DESCRIPTION = 3. (ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.2.15)(PORT = 1521)) 4. (CONNECT_DATA = 5. (SERVER = DEDICATED) 6. (SERVICE_NAME = CDB001) 7. ) 8. ) 9. 10. PDB001 = 11. (DESCRIPTION = 12. (ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.2.15)(PORT = 1521)) 13. (CONNECT_DATA = 14. (SERVER = DEDICATED) 15. (SERVICE_NAME = PDB001) 16. ) 17. ) To clone the source pluggable database PDB001 I need to open it in READ ONLY mode view plainprint? 1. SQL> select name, open_mode from v$pdbs; 2. 3. NAME OPEN_MODE 4. ------------------------------ ---------- 5. PDB$SEED READ ONLY 6. PDB001 READ WRITE 7. PDB002 READ WRITE 8. 9. SQL> alter pluggable database PDB001 open read only force; 10. 11. Pluggable database altered. On my file system I have the following directories and files. view plainprint? 1. [oracle@localhost CDB001]$ pwd 2. /app/oracle/oradata/CDB001 3. [oracle@localhost CDB001]$ ll 4. total 2163224 5. -rw-r-----. 1 oracle oinstall 17973248 Jul 30 13:12 control01.ctl 6. drwxr-x---. 2 oracle oinstall 4096 Jul 20 15:29 PDB001 7. drwxr-x---. 2 oracle oinstall 4096 Jul 20 16:22 PDB002 8. drwxr-x---. 2 oracle oinstall 4096 Jul 15 22:07 pdbseed 9. -rw-r-----. 1 oracle oinstall 52429312 Jul 30 13:12 redo01.log 10. -rw-r-----. 1 oracle oinstall 52429312 Jul 29 22:06 redo02.log 11. -rw-r-----. 1 oracle oinstall 52429312 Jul 30 02:32 redo03.log 12. -rw-r-----. 1 oracle oinstall 817897472 Jul 30 13:11 sysaux01.dbf 13. -rw-r-----. 1 oracle oinstall 817897472 Jul 30 13:06 system01.dbf 14. -rw-r-----. 1 oracle oinstall 76554240 Jul 30 13:11 temp01.dbf 15. -rw-r-----. 1 oracle oinstall 325066752 Jul 30 13:10 undotbs01.dbf 16. -rw-r-----. 1 oracle oinstall 5251072 Jul 30 02:37 users01.dbf Here is the content of PDB001 directory. view plainprint? 1. [oracle@localhost CDB001]$ ll PDB001/ 2. total 922516 3. -rw-r-----. 1 oracle oinstall 5251072 Jul 30 13:08 PDB001_users01.dbf 4. -rw-r-----. 1 oracle oinstall 665853952 Jul 30 13:08 sysaux01.dbf 5. -rw-r-----. 1 oracle oinstall 272637952 Jul 30 13:08 system01.dbf 6. -rw-r-----. 1 oracle oinstall 20979712 Jul 21 17:51 temp01.dbf I'm going to create a new pluggable database called PDB003, cloning PDB001. The command to clone a pluggable database locally is the following: view plainprint? 1. SQL> create pluggable database PDB003 from PDB001 file_name_convert=('/app/oracle/oradata/CDB001/PDB001','/app/oracle/oradata/CDB001/PDB003'); 2. 3. Pluggable database created. New files and directories are created. Note also the same name of the datafile PDB001_users01.dbf used as default tablespace for PDB003. view plainprint? 1. [oracle@localhost CDB001]$ ll 2. total 2163228 3. -rw-r-----. 1 oracle oinstall 17973248 Jul 30 13:19 control01.ctl 4. drwxr-x---. 2 oracle oinstall 4096 Jul 20 15:29 PDB001 5. drwxr-x---. 2 oracle oinstall 4096 Jul 20 16:22 PDB002 6. drwxr-x---. 2 oracle oinstall 4096 Jul 30 13:17 PDB003 7. drwxr-x---. 2 oracle oinstall 4096 Jul 15 22:07 pdbseed 8. -rw-r-----. 1 oracle oinstall 52429312 Jul 30 13:18 redo01.log 9. -rw-r-----. 1 oracle oinstall 52429312 Jul 29 22:06 redo02.log 10. -rw-r-----. 1 oracle oinstall 52429312 Jul 30 02:32 redo03.log 11. -rw-r-----. 1 oracle oinstall 817897472 Jul 30 13:18 sysaux01.dbf 12. -rw-r-----. 1 oracle oinstall 817897472 Jul 30 13:17 system01.dbf 13. -rw-r-----. 1 oracle oinstall 76554240 Jul 30 13:18 temp01.dbf 14. -rw-r-----. 1 oracle oinstall 325066752 Jul 30 13:16 undotbs01.dbf 15. -rw-r-----. 1 oracle oinstall 5251072 Jul 30 02:37 users01.dbf 16. [oracle@localhost CDB001]$ ll PDB003 17. total 921688 18. -rw-r-----. 1 oracle oinstall 5251072 Jul 30 13:18 PDB001_users01.dbf 19. -rw-r-----. 1 oracle oinstall 665853952 Jul 30 13:18 sysaux01.dbf 20. -rw-r-----. 1 oracle oinstall 272637952 Jul 30 13:18 system01.dbf 21. -rw-r-----. 1 oracle oinstall 20979712 Jul 30 13:17 temp01.dbf
  • 3. After the command is sucessfully completed the status and the open mode of the new pluggable database are NEW and MOUNTED. view plainprint? 1. SQL> select PDB_NAME, STATUS from CDB_PDBS; 2. 3. PDB_NAME STATUS 4. ---------- ------------- 5. PDB$SEED NORMAL 6. PDB001 NORMAL 7. PDB002 NORMAL 8. PDB003 NEW 9. 10. SQL> select name, open_mode from V$PDBS; 11. 12. NAME OPEN_MODE 13. ------------------------------ ---------- 14. PDB$SEED READ ONLY 15. PDB001 READ ONLY 16. PDB002 READ WRITE 17. PDB003 MOUNTED A new service is created too. view plainprint? 1. SQL> select name, pdb from V$SERVICES order by creation_date; 2. 3. NAME PDB 4. -------------------- ------------------------------ 5. CDB001XDB CDB$ROOT 6. SYS$BACKGROUND CDB$ROOT 7. CDB001 CDB$ROOT 8. SYS$USERS CDB$ROOT 9. pdb001 PDB001 10. pdb002 PDB002 11. pdb003 PDB003 You can now open both pluggable databases with one simply command (have a look at this post for more information about the syntax and examples) view plainprint? 1. SQL> alter pluggable database PDB001,PDB003 open READ WRITE FORCE; 2. 3. Pluggable database altered. 4. 5. SQL> select name, open_mode from V$PDBS; 6. 7. NAME OPEN_MODE 8. -------------------- ---------- 9. PDB$SEED READ ONLY 10. PDB001 READ WRITE 11. PDB002 READ WRITE 12. PDB003 READ WRITE 13. 14. SQL> select PDB_NAME, STATUS from CDB_PDBS; 15. 16. PDB_NAME STATUS 17. ---------- ------------- 18. PDB$SEED NORMAL 19. PDB001 NORMAL 20. PDB002 NORMAL 21. PDB003 NORMAL Add the following entry on the tnsnames.ora file. view plainprint? 1. PDB003 = 2. (DESCRIPTION = 3. (ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.2.15)(PORT = 1521)) 4. (CONNECT_DATA = 5. (SERVER = DEDICATED) 6. (SERVICE_NAME = PDB003) 7. ) 8. ) Let's see my data on PDB003 and on PDB001 view plainprint? 1. SQL> connect marcov/marcov@PDB003 2. Connected. 3. SQL> show con_name 4. 5. CON_NAME 6. ------------------------------ 7. PDB003 8. SQL> select count(*) from marcov.T1; 9. 10. COUNT(*) 11. ---------- 12. 100 13. 14. SQL> connect marcov/marcov@PDB001 15. Connected. 16. SQL> show con_name 17.
  • 4. 18. CON_NAME 19. ------------------------------ 20. PDB001 21. SQL> select count(*) from marcov.T1; 22. 23. COUNT(*) 24. ---------- 25. 100 It is not possible to create a new pdb cloning a local or a remote seed: to create a new pdb from the seed you have to follow this post. If you try to clone from the seed template you will receive the ORA-65000 error, described below: view plainprint? 1. SQL> create pluggable database PDB004 from PDB$SEED file_name_convert=('/app/oracle/oradata/CDB001/pdbseed','/app/oracle/oradata/CDB001/PDB004'); 2. create pluggable database PDB004 from PDB$SEED file_name_convert=('/app/oracle/oradata/CDB001/pdbseed','/app/oracle/oradata/CDB001/PDB004') 3. * 4. ERROR at line 1: 5. ORA-65000: missing or invalid pluggable database name 6. 7. [oracle@localhost pdbseed]$ oerr ora 65000 8. 65000, 00000, "missing or invalid pluggable database name" 9. // *Cause: A valid pluggable database name was not present where required 10. // by the syntax of a CREATE PLUGGABLE DATABASE, ALTER PLUGGABLE 11. // DATABASE or DROP PLUGGABLE DATABASE statement. 12. // *Action: Reissue the statement with a valid pluggable database name. That's all.