Oracle 12c CDB PDB
先说基本用法:
先按11G之前进行
conn / as sysdba;
create user test identifed by test;
ORA-65096: 公用用户名或角色名无效.
查官方文档得知“试图创建一个通用用户,必需要用C##或者c##开头”,这时候心里会有疑问,什么是common user?不管先建成功了再说
create C##user test identifed by test;
创建成功
SQL>show con_name;
CON_NAME
------------------------------
CDB$ROOT
selectcon_id,dbid,NAME,OPEN_MODEfromv$pdbs;
CON_ID DBID NAME OPEN_MODE
---------- ---------- ------------------------------ ----------
2 4066409480 PDB$SEED READ ONLY
3 2270995695 PDBORCL MOUNTED
SQL>alter session set container=PDBORCL;
这时再用create user test identifed by test;建立用户就可以了。
CDB和PDB是ORACLE 12C一个很亮的新特性,由于他们的引入导致传统的ORACLE数据库管理理念不少发生了改变,这里列举了部分最基本的cdb和pdb管理方式
cdb和pdb关系图

ORACLE 12C版本
SQL> select * from v$version;BANNER CON_ID-------------------------------------------------------------------------------- ----------Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production 0PL/SQL Release 12.1.0.1.0 - Production 0CORE 12.1.0.1.0 Production 0TNS for Linux: Version 12.1.0.1.0 - Production 0NLSRTL Version 12.1.0.1.0 - Production 0 |
启动关闭pdb
SQL> startupORACLE instance started.Total System Global Area 597098496 bytesFixed Size 2291072 bytesVariable Size 272632448 bytesDatabase Buffers 314572800 bytesRedo Buffers 7602176 bytesDatabase mounted.Database opened.SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs; CON_ID DBID NAME OPEN_MODE---------- ---------- ------------------------------ ---------- 2 4048821679 PDB$SEED READ ONLY 3 3313918585 PDB1 MOUNTED 4 3872456618 PDB2 MOUNTEDSQL> alter PLUGGABLE database pdb1 open;Pluggable database altered.SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs; CON_ID DBID NAME OPEN_MODE---------- ---------- ------------------------------ ---------- 2 4048821679 PDB$SEED READ ONLY 3 3313918585 PDB1 READ WRITE 4 3872456618 PDB2 MOUNTEDSQL> alter PLUGGABLE database pdb1 close;Pluggable database altered.SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs; CON_ID DBID NAME OPEN_MODE---------- ---------- ------------------------------ ---------- 2 4048821679 PDB$SEED READ ONLY 3 3313918585 PDB1 MOUNTED 4 3872456618 PDB2 MOUNTEDSQL> alter PLUGGABLE database all open;Pluggable database altered.SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs; CON_ID DBID NAME OPEN_MODE---------- ---------- ------------------------------ ---------- 2 4048821679 PDB$SEED READ ONLY 3 3313918585 PDB1 READ WRITE 4 3872456618 PDB2 READ WRITESQL> alter PLUGGABLE database all close;Pluggable database altered.SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs; CON_ID DBID NAME OPEN_MODE---------- ---------- ------------------------------ ---------- 2 4048821679 PDB$SEED READ ONLY 3 3313918585 PDB1 MOUNTED 4 3872456618 PDB2 MOUNTEDSQL> alter session set container=pdb1;Session altered.SQL> startupPluggable Database opened.SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs; CON_ID DBID NAME OPEN_MODE---------- ---------- ------------------------------ ---------- 3 3313918585 PDB1 READ WRITE |
pdb的管理可以在cdb中进行也可以在pdb中进行,如果是cdb中进行,需要PLUGGABLE关键字,如果是pdb中直接和普通数据库一样
登录pdb
[oracle@xifenfei ~]$ lsnrctl statusLSNRCTL for Linux: Version 12.1.0.1.0 - Production on 12-MAY-2013 08:07:02Copyright (c) 1991, 2013, Oracle. All rights reserved.Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xifenfei)(PORT=1521)))STATUS of the LISTENER------------------------Alias LISTENERVersion TNSLSNR for Linux: Version 12.1.0.1.0 - ProductionStart Date 11-MAY-2013 18:30:54Uptime 0 days 13 hr. 36 min. 8 secTrace Level offSecurity ON: Local OS AuthenticationSNMP OFFListener Parameter File /u01/app/grid/product/12.1/network/admin/listener.oraListener Log File /u01/app/grid/diag/tnslsnr/xifenfei/listener/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=xifenfei)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=xifenfei)(PORT=5500))(Security=(my_wallet_directory=/u01/oracle/12.1/db_1/admin/cdb/xdb_wallet))(Presentation=HTTP)(Session=RAW))Services Summary...Service "+ASM" has 1 instance(s). Instance "+ASM", status READY, has 1 handler(s) for this service...Service "cdb" has 1 instance(s). Instance "cdb", status READY, has 1 handler(s) for this service...Service "cdbXDB" has 1 instance(s). Instance "cdb", status READY, has 1 handler(s) for this service...Service "pdb1" has 1 instance(s). Instance "cdb", status READY, has 1 handler(s) for this service...Service "pdb2" has 1 instance(s). Instance "cdb", status READY, has 1 handler(s) for this service...The command completed successfully[oracle@xifenfei ~]$ tnsping pdb1TNS Ping Utility for Linux: Version 12.1.0.1.0 - Production on 12-MAY-2013 08:07:09Copyright (c) 1997, 2013, Oracle. All rights reserved.Used parameter files:Used TNSNAMES adapter to resolve the aliasAttempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = xifenfei)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = pdb1)))OK (20 msec)[oracle@xifenfei ~]$ sqlplus sys/xifenfei@pdb1 as sysdbaSQL*Plus: Release 12.1.0.1.0 Production on Sun May 12 08:08:02 2013Copyright (c) 1982, 2013, Oracle. All rights reserved.Connected to:Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit ProductionWith the Partitioning, Automatic Storage Management, OLAP, Advanced Analyticsand Real Application Testing optionsSQL> show con_name;CON_NAME------------------------------PDB1[oracle@xifenfei ~]$ sqlplus / as sysdbaSQL*Plus: Release 12.1.0.1.0 Production on Sun May 12 08:09:14 2013Copyright (c) 1982, 2013, Oracle. All rights reserved.Connected to:Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit ProductionWith the Partitioning, Automatic Storage Management, OLAP, Advanced Analyticsand Real Application Testing optionsSQL> alter session set container=pdb1;Session altered.SQL> show con_name;CON_NAME------------------------------PDB1 |
pdb可以通过alter session container进入也可以直接通过tns方式登录
创建用户
SQL> show con_name;CON_NAME------------------------------CDB$ROOTSQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs; CON_ID DBID NAME OPEN_MODE---------- ---------- ------------------------------ ---------- 2 4048821679 PDB$SEED READ ONLY 3 3313918585 PDB1 READ WRITE 4 3872456618 PDB2 MOUNTEDSQL> create user xff identified by xifenfei;create user xff identified by xifenfei *ERROR at line 1:ORA-65096: invalid common user or role nameSQL> !oerr ora 6509665096, 00000, "invalid common user or role name"// *Cause: An attempt was made to create a common user or role with a name// that wass not valid for common users or roles. In addition to// the usual rules for user and role names, common user and role // names must start with C## or c## and consist only of ASCII // characters.// *Action: Specify a valid common user or role name.//SQL> create user c##xff identified by xifenfei;User created.SQL> SELECT USERNAME,CON_ID,USER_ID FROM CDB_USERS WHERE USERNAME='C##XFF';USERNAME CON_ID USER_ID---------- ---------- ----------C##XFF 1 103C##XFF 3 104SQL> alter session set container=pdb1;Session altered.SQL> show con_nameCON_NAME------------------------------PDB1SQL> create user xff identified by xifenfei;User created.SQL> create user c##abc identified by xifenfei;create user c##abc identified by xifenfei *ERROR at line 1:ORA-65094: invalid local user or role name |
创建用户默认的是container=all,在cdb中只能创建全局用户(c##开头),会在cdb和所有的pdb中创建该用户(但是pdb中的全局用户需要另外授权才能够在pdb中访问)。在pdb中只能创建的用户为本地用户
用户授权
SQL> grant connect to c##xff;Grant succeeded.SQL> select GRANTEE,con_id from cdb_ROLE_PRIVS where GRANTED_ROLE='CONNECT' AND GRANTEE='C##XFF';GRANTEE CON_ID------------------------------ ----------C##XFF 1SQL> grant resource to c##xff container=all;Grant succeeded.SQL> select GRANTEE,con_id from cdb_ROLE_PRIVS where GRANTED_ROLE='RESOURCE' AND GRANTEE='C##XFF';GRANTEE CON_ID------------------------------ ----------C##XFF 1C##XFF 3 |
用户授权默认情况下是只会给当前container,在cdb中也可以指定container=all,对所有open的pdb且存在该用户都进行授权
修改参数
SQL> alter system set open_cursors=500 container=all;System altered.SQL> conn sys/xifenfei@pdb1 as sysdbaConnected.SQL> show parameter open_cursors;NAME TYPE VALUE------------------------------------ ----------- ------------------------------open_cursors integer 500SQL> alter system set open_cursors=100; alter system set open_cursors=100*ERROR at line 1:ORA-01219: database or pluggable database not open: queries allowed on fixedtables or views onlySQL> alter database open;Database altered.SQL> alter system set open_cursors=100;System altered.SQL> show parameter open_cursors;NAME TYPE VALUE------------------------------------ ----------- ------------------------------open_cursors integer 100SQL> conn / as sysdbaConnected.SQL> show parameter open_cursors;NAME TYPE VALUE------------------------------------ ----------- ------------------------------open_cursors integer 500 |
这里可以看到在cdb中修改,pdb会继承进去;如果在pdb中修改会覆盖pdb从cdb中继承的参数含义
-------------------------------------------------------------------------------------------------------------------------------------------------
Oracle 12c CDB PDB的更多相关文章
- Oracle 12c CDB PDB 安装/配置/管理
Oracle安装参考:https://www.cnblogs.com/zhichaoma/p/9288739.html 对于CDB,启动和关闭与之前传统的方式一样,具体语法如下: STARTU ...
- oracle 12c 创建PDB用户即Local User (PDB与CDB)
Oracle 12C用户创建与表空间分配 数据库安装完成后,首先用系统用户链接数据库容器(CDB), 在数据库容器(CDB)中创建表空间‘imei’ SQL>create tablespace ...
- Oracle 12C CDB、PDB常用管理命令
Oracle 12C CDB.PDB常用管理命令 --查看PDB信息(在CDB模式下) show pdbs --查看所有pdbselect name,open_mode from v$pdbs; ...
- java开发连接Oracle 12c采用PDB遇到问题记录
今天初次使用java连接Oracle 12c,遇到各种问题,为方便后续查询,在汇总了问题记录及解决方案如下. ORA-28040: No matching authentication protoco ...
- Oracle 12c在PDB中创建scott/tiger
scott/tiger一直以来是oracle数据的默认用户,但是跟之前的版本相比,Oracle 12c引入了PDB管理,所以要麻烦一些 下面假设管理员为SYS/Oracle12csys,在orcl实例 ...
- 12C cdb/pdb 配置监听
. PDB is not an instance, so using SID in the connection string will not work. When the database is ...
- oracle 12c连接pdb
12c中,如何连接pluggable database: 使用默认的service连接pdb,创建pdb之后,在监听中自动添加以pdb为名的service: 用户在cluster中创建service, ...
- Oracle 12C -- CDB的启动过程
以启动DB12为例子 $ sqlplus '/as sysdba' SQL*Plus: Release Production on Sun Nov :: Copyright (c) , , Oracl ...
- Oracle 12C -- 删除PDB
删除PDB SQL> select con_id,pdb_name,status from cdb_pdbs; CON_ID PDB_NAME STATUS ---------- ------- ...
随机推荐
- [asp.net web api] HttpStatusCode的使用
摘要 在开放api的时,我们需要返回不同的状态给调用方,以告诉它们当前请求的结果,是成功了还是失败了.当然这种给调用方的反馈有很多种做法,这里就说是web api内置的对Http状态码.http状态码 ...
- github个人博客绑定单独阿里域名指南
详情:http://www.liu12fei08fei.top/ github个人博客绑定单独阿里域名指南 起源 禁止微信重拍版 给github pages绑定域名 获取github pages的ip ...
- mysql解决datetime与timestamp精确到毫秒的问题
CREATE TABLE `tab1` ( `tab1_id` VARCHAR(11) DEFAULT NULL, `create` TIMESTAMP(3) NULL DEFAULT NULL, ` ...
- python笔记29-队列Queue
前言 Python的Queue模块提供一种适用于多线程编程的FIFO实现.它可用于在生产者(producer)和消费者(consumer)之间线程安全(thread-safe)地传递消息或其它数据,因 ...
- Maven最佳实践:Maven仓库
什么是Maven仓库 在不用Maven的时候,比如说以前我们用Ant构建项目,在项目目录下,往往会看到一个名为/lib的子目录,那里存放着各类第三方依赖jar文 件,如log4j.jar,junit. ...
- [GIt] 团队工作效率分析工具gitstats
copy : http://www.cnblogs.com/ToDoToTry/p/4311637.html 如果你是团队领导,关心团队的开发效率和工作激情:如果你是开源软件开发者,维护者某个repo ...
- Android 跳转到系统应用管理
Intent i = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS");String pkg = " ...
- Visual Studio 调试方法
1:命令窗口 CTRL + D + I,可以在立即窗口中写一些临时的代码 2:编辑并继续 选中下面的选项,可以让你在调试暂停中,修改代码,而不用重新启动, 3:执行 单步执行:F10 跳进方法:F11 ...
- Kafka集群环境搭建(2.9.2-0.8.2.2)
Kafka是一个分布式.可分区.可复制的消息系统.Kafka将消息以topic为单位进行归纳:Kafka发布消息的程序称为producer,也叫生产者:Kafka预订topics并消费消息的程序称为c ...
- 软件project(一)——宏观总结
曾经看视频,看过去就忘.不想再这样子下去了,所以总结了好久.想让自己忘不了.这个过程花费时间有点长,可是假设让自己忘不了.一切都值了. 以下先来一张导图来总结一下<软件project>这门 ...