Sei sulla pagina 1di 9

CREATE PLUGGABLE DATABASE devpdb2 ADMIN USER sysdba identified by system DEFAULT

TABLESPACE USERS DATAFILE 'C:\app\Administrator\oradata\pdbsdb\user03.dbf \' SIZE 250M


AUTOEXTEND ON
FILE_NAME_CONVERT=('C:\app\Administrator\oradata\orcl\pdbseed\','C:\app\Administrator\oradata\o
rcl\pdbsdb\');

Cloning a PDB From an Existing PDB: Example The following statement


creates a PDB newpdb by cloning PDB salespdb. PDBs newpdb and salespdb are in the same
CDB. Because no storage limits are explicitly specified, there is no limit on the amount of
storage for newpdb. The files are copied from /disk1/oracle/dbs/salespdb/ to
/disk1/oracle/dbs/newpdb/. The location of all directory object paths associated with newpdb
are restricted to the directory /disk1/oracle/dbs/newpdb/.

CREATE PLUGGABLE DATABASE newpdb FROM pdbseed


FILE_NAME_CONVERT =(‘C:\app\Administrator\oradata\orcl\
pdbseed\’,’C:\app\Administrator\oradata\orcl\ newpdb \’)
PATH_PREFIX = ‘C:\app\Administrator\oradata\orcl\ newpdb’;

SELECT pdb_name, status

FROM cdb_pdbs

How to Find Out Default Permanent Tablespace

To find the default permanent tablespace in Oracle, you can run the following SELECT statement:
ALTER SESSION SET CONTAINER = PDBORCL;

SELECT PROPERTY_VALUE

FROM DATABASE_PROPERTIES

WHERE PROPERTY_NAME = 'DEFAULT_PERMANENT_TABLESPACE';

How to Find Out Default Temporary Tablespace

To find the default temporary tablespace in Oracle, you can run the following query:

SELECT PROPERTY_VALUE

FROM DATABASE_PROPERTIES

WHERE PROPERTY_NAME = 'DEFAULT_TEMP_TABLESPACE';

ALTER LOG FILE PATH;

C:\app\Administrator\diag\rdbms\orcl\orcl\trace

CREATE PLUGGABLE DATABASE PDB1 ADMIN USER SYSDBA IDENTIFIED BY "system" DEFAULT
TABLESPACE TEMP DATAFILE'C:\app\Administrator\oradata\PDB1.dbf' SIZE 10M AUTOEXTEND ON
FILE_NAME_CONVERT=('C:\app\Administrator\oradata\orcl\pdbseed\','C:\app\Administrator\oradata\P
DB1\');

CREATE PLUGGABLE DATABASE apex_approot1 AS APPLICATION CONTAINER admin user admin


IDENTIFIED BY java9118

FILE_NAME_CONVERT=('pdbseed','apex_approot1');
ALTER PLUGGABLE DATABASE apex_approot1 open;

find out pluggable database Read,write Mode;

selec name,open_mode,cdb from v$database;

find out how many pluggable database exist;

show pdbs;

Using DBCA(Database Configuration Assistance)By using this command Display a graphical Windows for
Create Pluggabldatabase;

desc v@pdbs;

--how to go inside the pluggable database ;

sho pdbs;

alter session set containter=pluggable_database_Name

FIND OUT PDB;

SELECT pdb_name, status FROM cdb_pdbs;

sho con_name;sho pdbs;

Oracle 12c Database New Features - Pluggable Database - Video 1

1. Pluggable Database
* Oracle 12c introduces a new feature called 'Pluggable Database'. Here Oracle Metadata and user data
are totally separated into two sections. One is Container DB (or CDB) which will hold Oracle Metadata.
The other is Pluggable DB (or PDB) which will hold user data.

How does a Pluggable Database work?

In the regular database, Oracle's metadata and user's application data are integrated. For beginners,
Oracle Metadata is the data that is present when you install a new Oracle Database (without any sample
schemas). Even though it can be called as an empty database, it still has data provided by Oracle. This
data is needed by the database to function. For example, the objects owned by SYS, SYSTEM are mostly
metadata.

Then user data is entered into that database. They will go under multiple user schemas. Now the
database is being used by the users.

Now a situation arises so that we need to create another database on the same server. Why? Let us say
that you need to provide data to two clients. And you don't want one client to other's data. And your
data is contained in an extensive set of application schemas.

In this case, making a copy of those applications schemas into a different set of names and making them
reside in the same database is very difficult.

So, you provide two separate databases. This also ensures that there is no security violation.

So, we install another new database, which comes with Oracle Metadata. Then we load the user data. In
this method, which is currently being used (Year 2013), there will be a need for more memory for both
the database instances. There will be two SGAs, two sets of smon, pmon and other background
processes running.

Then if we need to copy one database to another, we need to rely on extensive procedures which
includes exporting the data from the source database first, then removing the data at the target and
then finally loading the data in there. After that, we need to take care of the user security and object
privileges etc.

So, if you want to provide data for multiple tenants, that is multiple clients, then with the current set of
features (till Oracle 11g), we have to create multiple databases. That is, one database for one client. In
otherwords, there is no multi-tenancy.

Multi-Tenancy is becoming an important requirement in cloud infrastructure, these days. You would like
to have the ability of providing data to multiple clients from the same database system with full
confidence in security.

This can be achieved in Pluggable Database.

In a Pluggable Database, Oracle basically separates its metadata entirely from the user data. Metadata is
stored in a section called Container DB. Then the user data are stored in Pluggable DBs. It also stores
user metadata in the Pluggable DB.

By the way, what is user metadata? For example, earlier, the list of user accounts that exist in a
database is tightly inegrated with Oracle Metadata. Now, with the separation of Container DB and
Pluggable DB, the user accounts must exist in the Pluggable DB. So, the Pluggable DB not only contains
user data, but also some user metadata.

So, what are the benefits?

* Multi-Tenancy - We can bring in two Pluggable DBs under one Container DB. Both will be totally
segregated, but yet controlled by one instance. This is an important feature for SaaS (Software as a
Service) platforms, Cloud, On-Demand and Vendor Managed Application solutions.

* Easy cloning/copying. Now the cloning and copying the databases across servers would be much
easier. Just clone a Pluggable DB and plug-it-in in a different server.
* Very easy upgrades and patching.

CREATE PLUGGABLE DATABASE apex_approot1 AS APPLICATION CONTAINER admin user SYSDBA


IDENTIFIED BY system FILE_NAME_CONVERT= ('pdbseed','apex_approot1');

Create pluggable database pdbsdb admin user sysdba identified by system file_name_convert =
('C:\app\Administrator\oradata\orcl\pdb$seed\','C:\app\Administrator\oradata\orcl\ pdbsdb \');

Create pluggable database pdbsdb admin user system identified by “system” DEFAULT TABLESPACE
USER DATAFILE 'C:\app\Administrator\oradata\ pdbsdb\user02.dbf \' file_name_convert =
('C:\app\Administrator\oradata\orcl\pdbseed\','C:\app\Administrator\oradata\orcl\ pdbsdb \');

Seed Database (pdb$seed) - Read Write OR Read Only Mode in Oracle Database 12c
(12.1.0.1.0)

Connect to container database (cdb1)

SQL> connect sys/oracle@cdb1 as sysdba


Connected.

SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT

SQL> select open_mode from v$database;

OPEN_MODE
--------------------
READ WRITE

Perform close instance operation in seed database (pdb$seed)

SQL> alter pluggable database pdb$seed close;


alter pluggable database pdb$seed close
*
ERROR at line 1:
ORA-65017: seed pluggable database may not be dropped or altered

SQL> alter session set "_oracle_script"=TRUE;


Session altered.

Perform close instance operation in seed database (pdb$seed)

SQL> alter pluggable database pdb$seed close immediate instances=all;


Pluggable database altered.

SQL> select open_mode from v$database;

OPEN_MODE
--------------------
READ WRITE

SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT

Open the pdb$seed database in read write mode

SQL> alter pluggable database pdb$seed open read write;


Pluggable database altered.

SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT

SQL> alter session set container=PDB$SEED;


Session altered.

SQL> show con_name

CON_NAME
------------------------------
PDB$SEED

SQL> select open_mode from v$database;

OPEN_MODE
--------------------
READ WRITE

SQL> show pdbs

CON_ID CON_NAME OPEN MODE RESTRICTED


---------- ------------------------------ ---------- ----------
2 PDB$SEED READ WRITE NO

SQL> connect sys/oracle@cdb1 as sysdba


Connected.

Create Pluggable Database (cdb1_pdb4) in Container Database (cdb1)

SQL> show pdbs

CON_ID CON_NAME OPEN MODE RESTRICTED


---------- ------------------------------ ----------------- ----------
2 PDB$SEED READ WRITE NO
3 CDB1_PDB3 MOUNTED

create pluggable database cdb1_pdb4 admin user user1 identified by oracle


*
ERROR at line 1:
ORA-65081: database or pluggable database is not open in read only mode

Close the pdb$seed and open it in read only mode

SQL> alter pluggable database pdb$seed close immediate instances=all;


Pluggable database altered.

SQL> alter pluggable database pdb$seed open read only;


Pluggable database altered.

SQL> show con_name


CON_NAME
------------------------------
PDB$SEED

SQL> select open_mode from v$database;

OPEN_MODE
--------------------
READ ONLY

Set the parameter "_oracle_script" and create pluggable database (cdb1_pdb4)

SQL> alter session set "_oracle_script"=FALSE;


Session altered.

SQL> create pluggable database cdb1_pdb4 admin user user1 identified by oracle;
Pluggable database created.

SQL> alter pluggable database cdb1_pdb4 open;


Pluggable database altered.

SQL> show pdbs

CON_ID CON_NAME OPEN MODE RESTRICTED


---------- ------------------------------ ---------------- ----------
2 PDB$SEED READ ONLY NO
3 CDB1_PDB3 MOUNTED
4 CDB1_PDB4 READ WRITE NO

SQL> alter session set container=cdb1_pdb4;


Session altered.

Conclusion: pdb$seed is template database for new pluggable databases in container database (cdb).

Posted by Y.V RaviKumar at 12:27 AM

1 comment:

Potrebbero piacerti anche