博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[Oracle] - Connect to a PDB of Oracle12c
阅读量:4648 次
发布时间:2019-06-09

本文共 2993 字,大约阅读时间需要 9 分钟。

Story about CDB and PDB

Oracle12c has a new feature and definition of CDB and PDB. If you first use 12c you will get confused like me. So that is necessary to know some basic definitions before you start. Oracle's official document is always the best material.

Login a CBD

[oracle@ol65 ~]$ sqlplus /nologSQL*Plus: Release 12.1.0.2.0 Production on Mon Oct 27 23:07:56 2014Copyright (c) 1982, 2014, Oracle.  All rights reserved.SQL> conn sys@orcl as sysdbaEnter password: Connected.SQL> sho con_nameCON_NAME------------------------------CDB$ROOTSQL>
** sho con_name - show current container name. Root container is always called CDB#ROOT.

How many PDBs in your root container now?

SQL> sho pdbs    CON_ID CON_NAME			  OPEN MODE  RESTRICTED---------- ------------------------------ ---------- ----------	 2 PDB$SEED			  READ ONLY  NO	 3 PDBORCL			  MOUNTEDSQL>
** PDB$SEED is a seed PDB, as its name Oracle12c will take is
    Default status of a new PDB is mounted. It's not running, you have to 'open' it before you start using it.

Open a PDB

You must have sysdba privilege.
SQL> alter pluggable database PDBORCL open;Pluggable database altered.SQL> sho pdbs    CON_ID CON_NAME			  OPEN MODE  RESTRICTED---------- ------------------------------ ---------- ----------	 2 PDB$SEED			  READ ONLY  NO	 3 PDBORCL			  READ WRITE NOSQL>

Login a PDB

SQL> sho con_nameCON_NAME------------------------------CDB$ROOTSQL> alter session set container=PDBORCL;Session altered.SQL> sho con_nameCON_NAME------------------------------PDBORCLSQL>
Now you login a PDB. Now you can create a new user as you operate a Oracle DB before 12c. This user is not common user. It's a user for this PDB. You also can understand PDB as a general DB of the version before 12c.

Login Root Container again and Stop a PDB

SQL> conn sys as sysdbaEnter password: Connected.SQL> alter pluggable database PDBORCL close immediate;Pluggable database altered.SQL>

Register a Entry of a PDB

Edit config file /$ORACLE_HOME/network/admin/tnsnames.ora.
ORCL =  (DESCRIPTION =    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))    (CONNECT_DATA =      (SERVER = DEDICATED)      (SERVICE_NAME = orcl.localdomain)    )  )PDBORCL =  (DESCRIPTION =    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))    (CONNECT_DATA =      (SERVER = DEDICATED)      (SERVICE_NAME = pdborcl.localdomain)    )  )
Save and quit. Go to open this PDB again. Now you can access PDBORCL by service name.
[oracle@ol65 admin]$ sqlplus sys@pdborcl as sysdbaSQL*Plus: Release 12.1.0.2.0 Production on Tue Oct 28 00:08:52 2014Copyright (c) 1982, 2014, Oracle.  All rights reserved.Enter password: Connected to:Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit ProductionWith the Partitioning, OLAP, Advanced Analytics and Real Application Testing optionsSQL>
And the most importance is that now you are able to remotely connect this PDB!
Now you application can use this DB as well.

转载于:https://www.cnblogs.com/yangykaifa/p/6973744.html

你可能感兴趣的文章
冰封的海盗攻略
查看>>
Netty4.x中文教程系列(四) 对象传输
查看>>
linux下find命令使用举例、
查看>>
GET请求在Tomcat中的传递及URI传递
查看>>
ubuntun 服务器与Mac
查看>>
重温JSP学习笔记--与日期数字格式化有关的jstl标签库
查看>>
java-Date-DateFormat-Calendar
查看>>
封装CLLocationManager定位获取经纬度
查看>>
我的第一篇博客-(Eclipse中或Myeclipse中如果不小心删除了包那可怎么办?)
查看>>
对easyui datagrid组件的一个小改进
查看>>
类似以下三图竞争关系的IT企业
查看>>
清明节
查看>>
ubuntu如何安装svn客户端?
查看>>
javascript之非构造函数的继承
查看>>
C#实现 单点登录(SSO)
查看>>
高精度计算(2015.8.1)
查看>>
cocos2d-x tile map瓦片地图的黑线及地图抖动解决方案
查看>>
软工网络15团队作业2——团队计划
查看>>
计算机专业及软件开发推荐书籍
查看>>
《Java程序设计》 课程教学
查看>>