详谈Oracle12c新特点容器数据库&可插拔数据库(CDB&PDB)

一般信息


数据字典


CDB_FILE$


DBA_PDBS


PDB$SEED


CDB_LOCAL_ADMINAUTH$


DBA_PDB_HISTORY


PDB_HISTORY$


CDB_PDB_SAVED_STATES


DBA_PDB_SAVED_STATES


PDB_PLUG_IN_VIOLATIONS


CDB_RESOURCE_PLAN$


DBMS_PDB


PDB_SPFILE$


CDB_RESOURCE_PLAN_DIRECTIVE$


DBMS_PDB_EXEC_SQL


V$CONTAINERS


CDB_SERVICE$


GV$CONTAINERS


V$PDBS


CDB_HIST_PDB_INSTANCE


GV$PDBS


V$PDB_INCARNATION


CDB_PDBS


GV$PDB_INCARNATION


WRI$_ADV_ADDM_PDBS


CDB_PDB_HISTORY


GV$SESSIONS_COUNT


WRM$_PDB_INSTANCE


CONTAINERS


INT$DBA_PDB_SAVED_STATES


XDB$CDBPORTS


DBA_HIST_PDB_INSTANCE


PDB_ALERT$


角色


CDB_DBA


系统权限


CREATE PLUGGABLE DATABASE


SET CONTAINER


SET CONTAINER


探究SEED PDB

 

从PDB$SEED创建PDB


语法:

CREATE PLUGGABLE DATABASE

ADMIN USER IDENTIFIED BY

FILE_NAME_CONVERT = (‘‘, ‘‘)

ROLES = ()

DEFAULT TABLESPACE [DATAFILE ]

EXTENT MANAGEMENT LOCAL <autoallocate |="" uniform="" size="" >

STORAGE ];

例子:


col con_name format a10

col restricted format a10

SELECT v.name, v.open_mode, v.restricted, d.status

FROM v$pdbs v, dba_pdbs d

WHERE v.guid = d.guid

ORDER BY v.create_scn;

NAME                           OPEN_MODE  RESTRICTED STATUS

------------------------------ ---------- ---------- -------------

PDB$SEED                       READ ONLY  NO         NORMAL

ALTER PLUGGABLE DATABASE pdb1 OPEN;

SELECT v.name, v.open_mode, v.restricted, d.status

FROM v$pdbs v, dba_pdbs d

WHERE v.guid = d.guid

ORDER BY v.create_scn;

NAME                           OPEN_MODE  RESTRICTED STATUS

------------------------------ ---------- ---------- -------------

PDB$SEED                       READ ONLY  NO         NORMAL

SELECT * FROM dba_pdbs;

-- 12.1.0.1 version

-- SELECT * FROM cdb$view(dba_pdbs);

-- 12.1.0.2 versionSELECT * FROM containers(dba_pdbs);

-- 12.1.0.1 version

-- SELECT * FROM cdb$view(cdb_pdbs);

-- 12.1.0.2 version

SELECT * FROM containers(cdb_pdbs);

SELECT table_name, tablespace_name, con_id

FROM containers(dba_tables)

WHERE rownum < 6;


CREATE PLUGGABLE DATABASE pdb1

ADMIN USER TEST IDENTIFIED BY TEST

FILE_NAME_CONVERT = (‘/pdbseed/‘, ‘/pdb1/‘);

SELECT v.name, v.open_mode, NVL(v.restricted, ‘n/a‘) RESTRICTED, d.status

FROM v$pdbs v, dba_pdbs d

WHERE v.guid = d.guid

ORDER BY v1;

NAME                           OPEN_MODE  RESTRICTED STATUS

------------------------------ ---------- ---------- -------------

PDB1                         MOUNTED    NO         NORMAL

PDB$SEED                       READ ONLY  NO         NORMAL

ALTER SESSION SET CONTAINER=pdb1;

sho con_name

CON_NAME

-------------------

PDB1

ALTER PLUGGABLE DATABASE pdb1 OPEN;

SELECT COUNT(*)FROM dba_tables;


探究数据文件


desc dba_data_files

desc cdb_data_files

SELECT file_name, tablespace_name, online_status

FROM dba_data_files;

SELECT file_name, tablespace_name, online_status, con_id

FROM cdb_data_files;


探究用户


desc dba_users

desc cdb_users

SELECT username, account_status, lock_date, expiry_date

FROM dba_users

ORDER BY 1;

SELECT username, default_tablespace, temporary_tablespace

FROM dba_users

ORDER BY 1;

SELECT username, default_tablespace, temporary_tablespace, con_id

FROM cdb_users

ORDER BY 1;

SELECT username, default_tablespace, temporary_tablespace, con_id

FROM cdb_users

WHERE username like ‘TE%‘

ORDER BY 1;

ALTER PLUGGABLE DATABASE pdb1 OPEN;

SELECT v.name, v.open_mode, NVL(v.restricted, ‘n/a‘) "RESTRICTED", d.status

FROM v$pdbs v, dba_pdbs d

WHERE v.guid = d.guid

ORDER BY v.create_scn;

NAME                           OPEN_MODE  RESTRICTED STATUS

------------------------------ ---------- ---------- -------------

PDB$SEED                       READ ONLY  NO         NORMAL

PDB1 READ WRITE NO         NORMAL

SELECT username, default_tablespace, temporary_tablespace, con_id

FROM cdb_users

WHERE username like ‘TE%‘

ORDER BY 1;


连接创建PDB


SQL> conn [email protected] as sysdba

Enter password: *********Connected.

SQL> GRANT create session TO TEST;

Grant succeeded.

SQL> SELECT COUNT(*) FROM cdb_sys_privs;

COUNT(*)

0

SQL> SELECT COUNT(*) FROM dba_sys_privs;

COUNT(*)

987

SQL> SELECT privilege, admin_option, common

FROM dba_sys_privs

WHERE grantee = ‘TEST‘;

PRIVILEGE                                ADM COM

---------------------------------------- --- ---

CREATE SESSION                           NO  NO

col grantee format a30

col granted_role format a30

SELECT * FROM dba_role_privs

WHERE grantee = ‘TEST‘;

GRANTEE                        GRANTED_ROLE                   ADM DEF COM

------------------------------ ------------------------------ --- --- ---

TEST                        PDB_DBA                        YES YES NO


克隆PDB


从一个容器现有PDB克隆新的PDB


语法:

CREATE PLUGGABLE DATABASE FROM FILE_NAME_CONVERT=(‘‘, ‘<path‘);< span="" style="word-wrap: break-word;">

例子:


ALTER PLUGGABLE DATABASE pdb1 CLOSE;

ALTER PLUGGABLE DATABASE pdb1 OPEN READ ONLY;

CREATE OR REPLACE VIEW pdb_status AS

SELECT v.name, v.open_mode, NVL(v.restricted, ‘n/a‘) "RESTRICTED", d.status

FROM v$pdbs v, dba_pdbs d

WHERE v.guid = d.guid

ORDER BY v.create_scn;

SELECT * FROM pdb_status;

NAME                           OPEN_MODE  RESTRICTED STATUS

------------------------------ ---------- ---------- -------------

PDB$SEED                       READ ONLY  NO         NORMAL

PDB1                        READ ONLY  NO         NORMAL

CREATE PLUGGABLE DATABASE pdb1_t FROM pdb1FILE_NAME_CONVERT = (‘\uwpdb\‘, ‘\uwpdbd\‘);

SELECT * FROM pdb_status;

NAME                           OPEN_MODE  RESTRICTED STATUS

------------------------------ ---------- ---------- -------------

PDB$SEED                       READ ONLY  NO         NORMAL

PDB1                        READ ONLY  NO         NORMAL


创建时的UNPLUG/PLUGPDB


Unplug 子句


Unplug 子句

从unplugged创建


语法:

ALTER PLUGGABLE DATABASE UNPLUG INTO ‘‘;

例子:


conn / as sysdba

ALTER PLUGGABLE DATABASE pdb1 CLOSE;

ALTER PLUGGABLE DATABASE pdb1 UNPLUG INTO ‘pdb1.xml‘;

-- 将文件ftp到新服务器

-- the xml 文件在 $ORACLE_HOME/database下

SQL> CREATE PLUGGABLE DATABASE pdb2 USING ‘pdb1.xml‘

SOURCE_FILE_NAME_CONVERT = (‘\pdb1\‘, ‘\pdb2\‘)

NOCOPY

STORAGE (MAXSIZE 1G MAX_SHARED_TEMP_SIZE 20M)

TEMPFILE REUSE;


更改PDB


设置子句


默认版本


语法:

ALTER PLUGGABLE DATABASE

例子:


conn / as sysdba

ALTER SESSION SET CONTAINER = pdb1;

CREATE EDITION test_ed;

ALTER PLUGGABLE DATABASE pdb1 DEFAULT EDITION = test_ed;


默认表空间


语法:

ALTER PLUGGABLE DATABASE DEFAULT TABLESPACE ;

例子:


conn / as sysdba

ALTER SESSION SET CONTAINER = pdb1;

SELECT tablespace_nameFROM dba_tablespaces;

ALTER PLUGGABLE DATABASE pdb1 DEFAULT TABLESPACE oradata;


默认表空间类型


ALTER PLUGGABLE DATABASE SET DEFAULT TABLESPACE;


conn / as sysdba

ALTER SESSION SET CONTAINER = pdb1;

ALTER PLUGGABLE DATABASE pdb1 SET DEFAULT BIGFILE TABLESPACE;


默认临时表空间


ALTER PLUGGABLE DATABASE DEFAULT TEMPORARY TABLESPACE ;;


conn / as sysdba

ALTER SESSION SET CONTAINER = pdb1;

ALTER PLUGGABLE DATABASE pdb1 DEFAULT TEMPORARY TABLESPACEtemp_grp;


重命名


语法:

ALTER PLUGGABLE DATABASE RENAME GLOBAL_NAME TO [.domain];

例子:


conn / as sysdba

ALTER SESSION SET CONTAINER = pdb1;

SELECT *FROM global_name;

ALTER PLUGGABLE DATABASE pdb1 RENAME GLOBAL_NAME TO pdb$dev;


PDB内设置时区


语法:

ALTER PLUGGABLE DATABASE [] SET TIME_ZONE = ‘‘;

ALTER PLUGGABLE DATABASE SET TIME_ZONE = ‘< | -> HH:MI‘;

例子:


conn [email protected] as sysdba

ALTER SESSION SET CONTAINER = pdb1;

SELECT value$ FROM props$

WHERE name = ‘DBTIMEZONE‘;

ALTER PLUGGABLE DATABASE pdb1 SET TIME_ZONE = ‘Japan‘;

SELECT value$FROM props$WHERE name = ‘DBTIMEZONE‘;

ALTER PLUGGABLE DATABASE pdb1 SET TIME_ZONE = ‘00:00‘;

SELECT value$FROM props$WHERE name = ‘DBTIMEZONE‘;

 

数据文件重命名


语法:

ALTER PLUGGABLE DATABASE RENAME FILE ‘‘ TO ‘‘;


例子:

conn [email protected] as sysdba

ALTER PLUGGABLE DATABASE CLOSE;
?
?ALTER PLUGGABLE DATABASE pdb1

RENAME FILE ‘C:\APP\ORACLE\ORADATA\PDB1\PDB11.DBF‘

TO ‘C:\APP\ORACLE\ORADATA\PDB1\PDB101.DBF‘;

--原数据文件需手工去除


创建数据文件


ALTER PLUGGABLE DATABASE CREATE DATAFILE <‘‘ | filenumber> [AS | NEW]


更改数据文件


ALTER PLUGGABLE DATABASE DATAFILE <‘‘ | filenumber> <online |="" offline="" [for="" drop]="" resize="" | | END BACKUP>;


更改临时文件


ALTER PLUGGABLE DATABASE TEMPFILE <‘‘ | filenumber> <resize |="" | DROP [INCLUDING DATAFILES] | ONLINE | OFFLINE>;


移除数据文件


ALTER PLUGGABLE DATABASE MOVE DATAFILE <‘‘ | ASM_file_name | filenumber>TO ‘‘ [REUSE] [KEEP]


补充日志


语法:

ALTER PLUGGABLE DATABASE SUPPLEMENTAL LOG <data |="" | >

例子:


ALTER PLUGGABLE DATABASE pdb1 ADD SUPPLEMENTAL LOG DATA;


存储参数


语法:

ALTER PLUGGABLE DATABASE STORAGE <unlimited |="" >;

例子:


ALTER PLUGGABLE DATABASE pdb1 STORAGE UNLIMITED;


例子:

ALTER PLUGGABLE DATABASE STORAGE (MAX_SHARED_TEMP_SIZE <unlimited |="" );

例子:


ALTER PLUGGABLE DATABASE pdb1 STORAGE (MAX_SHARED_TEMP_SIZE UNLIMITED);


Datafile子句


数据文件联机/脱机


语法:

ALTER PLUGGABLE DATABASE DATAFILE ALL ;


例子:

conn / as sysdba

ALTER SESSION SET CONTAINER = pdb1;

ALTER PLUGGABLE DATABASE pdb1 CLOSE;

SELECT open_modeFROM v$pdbs;

SELECT file#, status, enabledFROM v$datafile;

ALTER PLUGGABLE DATABASE pdb1 DATAFILE ALL OFFLINE;

ALTER PLUGGABLE DATABASE pdb1 DATAFILE ALL ONLINE;

SELECT file#, status, enabledFROM v$datafile;

ALTER PLUGGABLE DATABASE pdb1 OPEN;


Recovery子句


备份和恢复PDB


语法:

ALTER PLUGGABLE DATABASE RECOVER [AUTOMATIC] [FROM ‘‘  DATABASE;例子:


ALTER PLUGGABLE DATABASE pdb1 RECOVER AUTOMATIC DATABASE;


语法:

ALTER PLUGGABLE DATABASE BACKUP;

例子:


conn / as sysdba

SHUTDOWN IMMEDIATE;

STARTUP MOUNT;

ALTER DATABASE ARCHIVELOG;

ALTER DATABASE OPEN;

ALTER PLUGGABLE DATABASE pdb1 OPEN;

ALTER SESSION SET CONTAINER = PDB1;

ALTER PLUGGABLE DATABASE pdb1 BEGIN BACKUP;

ALTER PLUGGABLE DATABASE pdb1 END BACKUP;


Change 子句


读写模式打开


语法:

ALTER PLUGGABLE DATABASE OPEN READ [WRITE] [UPGRADE] [RESTRICTED] [FORCE][INSTANCES = <(‘‘ | )] >);

例子:


ALTER PLUGGABLE DATABASE pdb1 OPEN;


只读模式打开


语法:

ALTER PLUGGABLE DATABASE OPEN READ ONLY ;

例子:


ALTER PLUGGABLE DATABASE pdb1 OPEN READ ONLY;


Resetlogs模式打开


语法:

ALTER PLUGGABLE DATABASE OPEN RESETLOGS ;

例子:


ALTER PLUGGABLE DATABASE pdb1 OPEN RESETLOGS;


打开/关闭PDB


语法:

ALTER PLUGGABLE DATABASE CLOSE [IMMEDIATE];


例子:

ALTER PLUGGABLE DATABASE pdb1 CLOSE;


打开/关闭所有PDB


语法:

ALTER PLUGGABLE DATABASE ALL CLOSE [IMMEDIATE];


例子:

ALTER PLUGGABLE DATABASE ALL CLOSE;


只读模式打开PDB


语法:

ALTER PLUGGABLE DATABASE READ ONLY;

例子:


conn / as sysdba

ALTER PLUGGABLE DATABASE pdb1 OPEN READ ONLY;


以READ ONLY RESTRICTED模式打开PDB


语法:

ALTER PLUGGABLE DATABASE OPEN READ ONLY RESTRICTED;

例子:


conn / as sysdbaALTER PLUGGABLE DATABASE pdb1 CLOSE;ALTER PLUGGABLE DATABASE pdb1 OPEN READ ONLY RESTRICTED;


移除PDB


从容器中删除PDB


语法:

DROP PLUGGABLE DATABASE [INCLUDING DATAFILES];

例子:


ALTER PLUGGABLE DATABASE pdb1 CLOSE;DROP PLUGGABLE DATABASE pdb1 INCLUDING DATAFILES;

原文地址:https://www.cnblogs.com/lhdz_bj/p/9104539.html

时间: 2024-11-05 17:32:29

详谈Oracle12c新特点容器数据库&amp;可插拔数据库(CDB&amp;PDB)的相关文章

理解及应用 Oracle 12c 插拔数据库

一.概述 1.Oracle 12c 可插拔数据库体系结构 Oracle 12c 中引入了一个新功能就是Oracle Multitenant,这个功能可以在多租户容器数据库中,创建并维护许多个可插拔数据库.Oracle Multitenant是Oracle企业版中需要额外付费的组件.然而,在所有Oracle版本中都可以在一个可插拔数据库中免费使用它.多租户容器数据库(CDB)是指能够容纳一个或者多个可插拔数据库的数据库.容器是指CDB中的数据文件和元数据的集合.可插拔数据库是指可以通过克隆另一个数

oracle12c新特点——可插拔数据库(Pluggable Database,PDB)

1.    12c PDB新特点的优势 1)    可以把多个PDB集成进一个平台. 2)    可以快速提供一个新的PDB或一个已有PDB的克隆. 3)    通过拔插技术,可以快速把存在的数据库重新部署到一个新平台上. 4)    多个PDB数据库补丁或升级一次完成. 5)    通过把单个PDB拔插到较高版本的不同CDB,可以补丁或升级一个PDB. 6)    从同一个CDB中众多PDB中分离出某个PDB的内容. 7)    分离这些PDB应用管理员的责任. 2.    12c PDB新特

Oracle12c中配置实例参数和修改容器数据库(CDB)及可插拔数据库(PDB)

Oracle12c中的多宿主选项允许一个容器数据库(CDB)容纳多个独立的可插拔数据库(PDB).本文将展示如何配置实例参数和修改容器数据库(CDB)及可插拔数据库(PDB).1. 配置CDB中的实例参数(ALTER SYSTEM)配置CDB实例参数和配置非CDB实例参数没什么不一样.ALTER SYSTEM命令用来设置初始化参数,而有些数据库配置修改需要用ALTER DATABASE命令.作为一个特权用户登录且连接到根容器时,任何ALTER SYSTEM命令默认都将作用于该根容器.这意味着如下

Oracle 12C 新特性 - “可插拔数据库”功能

Oracle 12C加入了一个非常有新意的功能"可插拔数据库"特性,实现了数据库(PDB)在"容器"(CDB)上的拔功能,既能提高系统资源的利用率,也简化大面积数据库的管理和迁移工作. 下面我们体验一下可插拔数据库的CDB和PDB的操作: 基本信息:根容器(CDB):CUP可插拔数据库(PDB):TEA 启动根容器:[[email protected] ~]$ export ORACLE_SID=cup[[email protected] ~]$ sqlplus /

玩转Oracle之12c 可插拔数据库数据泵功能体验

:数据泵可以高效备份.复制.保护和传输大量的数据和源数据.在导入和导出过程中可以做到过滤数据和对象,并且能够在全数据库级.方案级.表级和表空间级实现导入导出. Oracle12c的datapump功能跟以前差不多,在多租户的环境中执行导入\导出以及使用一些更细化的参数的时候,几乎没有区别,依然很好用,效率很高.目前有很多的用户仍然在使用exp/imp工具在执行一些迁移.备份.过滤和转移数据的工作,相比起来,数据泵的效率更高.更易用并且更方便管理,但exp/imp在有些时候可以完成datapump

如何连接oracle 12c可插拔数据库

启动根容器:[oracle@eric ~]$ export ORACLE_SID=cup[oracle@eric ~]$ sqlplus / as sysdbaSQL*Plus: Release 12.1.0.2.0 Production on Wed Jan 21 16:00:06 2015Copyright (c) 1982, 2014, Oracle. All rights reserved.Connected to an idle instance.SQL> startup -----不

浅谈Oracle12c 数据库、用户、CDB与PDB之间的关系

名词介绍: 数据库:数据库(Database)是按照数据结构来组织.存储和管理数据的仓库,它产生 于距今六十多年前,随着信息技术和市场的发展,特别是二十世纪九十年代以 后,数据管理不再仅仅是存储和管理数据,而转变成用户所需要的各种数据管 理的方式.C D B:CDB全称为Container Database,中文翻译为容器数据库.P D B:PDB全称为Pluggable Database,中文翻译为可插拔数据库. 首先,我来谈一下数据库.user和schema之间的关系.在我看,数据库就像是含

Oracle12C新特性——cdb与pdb

Oracle 12C引入了CDB与PDB的新特性,在ORACLE 12C数据库引入的多租用户环境(Multitenant Environment)中,允许一个数据库容器(CDB)承载多个可插拔数据库(PDB).CDB全称为Container Database,中文翻译为数据库容器,PDB全称为Pluggable Database,即可插拔数据库.在ORACLE 12C之前,实例与数据库是一对一或多对一关系(RAC):即一个实例只能与一个数据库相关联,数据库可以被多个实例所加载.而实例与数据库不可

Oracle12c多租户如何连接到CDB或PDB、CDB与PDB容器切换

Oracle 数据库 12 c 多租户选项允许单个容器数据库 (CDB) 来承载多个单独的可插拔数据库 (PDB).那么我们如何连接到容器数据库 (CDB) 和可插拔数据库 (PDB). 1. V$SERVICES视图可以显示数据库中的可用服务.SQL> col pdb for a40SQL> col name for a30;SELECT name, pdb FROM v$services ORDER BY name;SQL> NAME       PDB---------------