iSelfSchooling.com  Since 1999     References  |  Search more  | Oracle Syntax  | Free Online Oracle Training

    Home      .Services     Login       Start Learning     Certification      .                 .Share your BELIEF(s)...

 

. Online Accounting        .Copyright & User Agreement   |
    .Vision      .Biography     .Acknowledgement

.Contact Us      .Comments/Suggestions       Email2aFriend    |

 

Oracle 12c New Features

Online Oracle Training

LESSON 07

Create a new pluggable database

 

You use the seed read only pluggable database to create a pluggable database. In this lesson, you will create a new PDB pluggable database named mypdb2 in mycdb

 

You can use either the dbca tool or SQL Developer or SQL command to create a pluggable database.

In this lesson, we use the SQL tool to create a PDB.

 

You need to create a system file to store the mypdb2 data (PDB) in there.

# cd /oradata/mycdb

# mkdir mypdb2

# cd mypdb2

# pwd

/oradata/mycdb/mypdb2

 

Run the mycdb profile and then connect to your "mycdb" root container.

# cd ~

# . ./.profile

# sqlplus /nolog

SQL> connect / as sysdba

SQL> CREATE PLUGGABLE DATABASE mypdb2 ADMIN USER mypdb2_admin

   2   IDENTIFIED BY mypass ROLES=(CONNECT)

   3   FILE_NAME_CONVERT=("/oradata/mycdb/pdbseed","/oradata/mycdb/mypdb2");

Pluggable database created.

Notice that you are duplicating the seed template from /oradata/mycdb/pdbseed to /oradata/mycdb/mypdb2.

 

Now, check to see that the mode of mypdb2 is open. Query the V$PDBS view.

SQL> SELECT con_id, name, open_mode, dbid FROM v$pdbs;

 

CON_ID

NAME

OPEN_MODE

DBID

2

PDB$SEED

READ ONLY

3654327692

3

MYPDB1

READ WRITE

6783241652

4

MYPDB2

MOUNTED

7549320153

Notice that the open_mode value for the mypdb2 pluggable database is "MOUNTED."

 

Change the mypdb2 pluggable database open mode to READ WRITE.

SQL> ALTER PLUGGABLE DATABASE mypdb2 OPEN;

 

Use the netca tool to create a net service name for the mypdb2 pluggable database and name it mypdb2

 

Login to the mypdb2 PDB as sysdba

# sqlplus /nolog

SQL> connect sys/mypass@mypdb2 as sysdba

 

You can use EasyConnect to the mypdb2 pluggable database as sysdba.

SQL> connect sys/mypass@localhost:1521/mypdb2 as sysdba

 

Connect as mypdb2_admin.

SQL> connect mypdb2_admin/mypass@mypdb2

 

Get the container name

SQL> show con_name

 

CON_NAME

MYPDB2

 

Getting the container ID:

SQL> show con_id

 

CON_ID

4

 

Query the service name of the mypdb2 pluggable database.

SQL> SELECT name FROM v$services;

 

NAME

mypdb2

 

Check the following queries:

SQL> SELECT tablespace_name, file_name, con_id FROM cdb_data_files ORDER BY 3;

 

TABLESPACE_NAME

FILE_NAME

CON_ID

SYSTEM

/oradata/mycdb/mypdb2/system01.dbf

4

SYSAUX

/oradata/mycdb/mypdb2/sysaux01.dbf

4

 

Query the data files using the DBA_DATA_FILES view. Assume you are connected to the mypdb2 pluggable database.

SQL> SELECT tablespace_name, file_name FROM dba_data_files;

 

TABLESPACE_NAME

FILE_NAME

SYSAUX

/oradata/mycdb/mypdb2/sysaux01.dbf

SYSTEM

/oradata/mycdb/mypdb2/system01.dbf

 

 

Notice that you only see the mypdb2 pluggable database data files.

 

Query the temp file of the mypdb2 container using the DBA_TEMP_FILES view.

SQL> SELECT tablespace_name, file_name FROM dba_temp_files;

 

TABLESPACE_NAME

FILE_NAME

TEMP

/oradata/mycdb/mypdb2/temp01.dbf

Notice that the TEMP tablespace is on the mypdb2 pluggable databases.

 

The above queries against the CDB_ or DBA_ views show only connected container. To access to all the objects, you need to login to the root.

 

Good Luck!

 

 

Google
 
Web web site