CDB and PDB simple management operations for ORACLE12CR2

Source: Internet
Author: User
Tags reserved sqlplus

Oracle 12Cintroduced aCDBwith thePDBthe new feature, inORACLE 12Cthe Multi-tenancy environment introduced by the database (multitenant Environment), allow a database container (CDB) to host multiple pluggable databases (PDB). CDBall calledContainer Database, the Chinese translation is a database container,PDBall calledPluggable Database, you can plug and unplug the database. In theORACLE 12CPreviously, the instance and database were one-to-many relationships (RAC: That is, an instance can be associated with only one database, and the database can be loaded by multiple instances. The instance and database cannot be a one-to-many relationship. When enteringORACLE 12C, the instance can be a one-to-many relationship with the database. Here is the official documentation aboutCDBwith thePDBdiagram of the diagram.

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/8E/A9/wKioL1jIqGahkIFFAADCjfOxFBQ373.png "title=" 1.png "alt=" Wkiol1jiqgahkiffaadcjfoxfbq373.png "/>

CDB Components ( Components of a CDB )

a CDB The Database container contains the following components:

ROOT Components

ROOTalso calledCdb$root,Store theORACLEthe provided metadata andCommon User,An example of meta data isORACLEprovided byPL/SQLthe source code of the package,Common Userrefers to a user that exists in each container.

SEED Components

Seed also called Pdb$seed, This is what you create PDBs database template, you cannot Seed To Add or modify an object in the. There is only one Seed in a CDB .

PDBs

CDB can have one or more PDBs , PDBs backwards compatible and can be manipulated as before in the database PDBs , this refers to most general operations.

Each of these components can be called a container. Therefore,ROOT (Root)is a container,Seed (seeds)is a container, eachPDBis a container. Each container isCDBhas a uniqueIDand name.

Here are some simple CDB and PDB and maintenance management examples on 12.2.0.1

1. Connect to CDB Database

or use Sqlplus/as sysdba to connect, as in previous versions

[Email protected] admin]$ sqlplus/as sysdbasql*plus:release 12.2.0.1.0 Production on Wed Mar 10:39:52 2017Copyright  (c) 1982, Oracle. All rights reserved. Connected to:oracle Database 12c Enterprise Edition Release 12.2.0.1.0-64bit production[email protected]>

2. See if the database is CDB

[Email protected]> Select cdb from V$database; CDB---YES

If yes then CDB if no is non-CDB

3. View the current container

[Email protected]> show Con_namecon_name------------------------------cdb$root

The connection is ROOT so it appears as Cdb$root, and if the PDB is connected, the instance name of the PDB is displayed.

4. View PDB information

--1[email protected]> select con_id,dbid,guid,name,open_mode from v$pdbs;     CON_ID       DBID GUID                               NAME                                                  Open_mode---------- ---------- -------------------------------- ------------------------------- ------------------- ----------         2   172801168 4aad025c72a1f4b0e05358e8ff0aac40 pdb$seed                                             read only--2[email protected ]> show pdbs    con_id con_name                        open  mode  restricted---------- ------------------------------ ---------- ----------          2 PDB$SEED                        read  only  no

The PDB is not created yet, so there is only one pdb$seed.

5. Create and delete pdb

Using the Create pluggable database, you can create a PDB from seed. The current container must be CDB root.

[Email protected]> show con_namecon_name------------------------------cdb$root[email  protected]> create pluggable database test_pdb admin user testadm  identified by  "RF"  roles= (CONNECT)  file_name_convert= ('/data/oradata/testdb/pdbseed ', '/ Data/oradata/testdb/test_pdb ')  path_prefix= '/data/oradata/testdb/test_pdb '; Pluggable database created. [email protected]> show pdbs    con_id con_name                         open mode  restricted---------- ------------------------------ ----------  ----------         2 PDB$SEED                         READ only  no         3 test_pdb                         mounted

Use drop pluggable database to remove PDB

Drop pluggable database test_pdb including datafiles;

6. Start and close the PDB

--Start [email protected]> alter pluggable database test_pdb open; Pluggable database altered. [email protected]> show pdbs    con_id con_name                         open mode  restricted---------- ------------------------------ ----------  ----------         2 PDB$SEED                         READ ONLY  NO         3 TEST_PDB                         read write no--off [email protected]> alter pluggable d atabase test_pdb close; Pluggable database altered. [email protected]> show pdbs    con_id con_name                         open mode  restricted---------- ------------------------------ ----------  ----------         2 PDB$SEED                         READ ONLY  NO         3 TEST_PDB                         mounted

7, the switch between the containers

[email protected]> alter session set CONTAINER=TEST_PDB; Session altered. [Email protected]> show Con_namecon_name------------------------------test_pdb

8. Direct connection to PDB using Sql*plus

Need to configure TNS

test_pdb = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = 10.255.232.88) (PORT = 1521)) (Connect_data = (SER VER = dedicated) (service_name = test_pdb)))

Connection

[[email protected] admin]$ sqlplus testadm/[email protected]_pdbsql*plus:release 12.2.0.1.0 Production on Wed Mar 15 11:3  0:21 2017Copyright (c) 1982, Oracle. All rights reserved. Connected to:oracle Database 12c Enterprise Edition Release 12.2.0.1.0-64bit production[email protected]_pdb>

9. Create table space in PDB

[email protected]> alter session set Container=test_pdbsession altered. [Email protected]> Create tablespace users datafile '/data/oradata/testdb/test_pdb/users01.dbf ' size 200m; Tablespace created. [Email protected]> select name from V$tablespace; NAME------------------------------Systemsysauxundotbs1tempusers

10. User Management

Only global users (C # #开头) can be created in CDB, and the user is created in CDB and all PDB (but global users in the PDB need additional authorization to be accessible in the PDB). Users that can only be created in the PDB are local users
[Email protected]> show Con_namecon_name------------------------------cdb$root[email protected]> Create user  Test identified by "ABCD", create user test identified by "ABCD" *error at line 1:ora-65096:invalid Common user or role Name[email protected]> create User C # #test identified by "ABCD"; User created. [email protected]> alter session set CONTAINER=TEST_PDB; Session altered. [Email protected]> Create user test identified by "ABCD"; User created.


Reference: http://www.xifenfei.com/2013/05/oracle-12c-pdb-%E7%AE%A1%E7%90%86%E4%BB%8B%E7%BB%8D1.html

Http://www.cnblogs.com/kerrycode/p/3386917.html

Official Document: http://docs.oracle.com/database/122/ADMIN/overview-of-managing-a-multitenant-environment.htm#ADMIN13507


This article is from the "DBA fighting!" blog, so be sure to keep this source http://hbxztc.blog.51cto.com/1587495/1906785

CDB and PDB simple management operations for ORACLE12CR2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.