Connect to a PDB of Oracle12c

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.

What is CBD and PDB and why introduce them?

Login a CBD

[[email protected] ~]$ <strong>sqlplus /nolog</strong>

SQL*Plus: Release 12.1.0.2.0 Production on Mon Oct 27 23:07:56 2014

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

SQL> conn [email protected] as sysdba
Enter password:
Connected.
SQL> sho con_name

CON_NAME
------------------------------
CDB$ROOT
SQL>

** 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			  MOUNTED
SQL>

** 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 NO
SQL>

Login a PDB

SQL> sho con_name

CON_NAME
------------------------------
CDB$ROOT
SQL> alter session set container=PDBORCL;

Session altered.

SQL> sho con_name

CON_NAME
------------------------------
PDBORCL
SQL>

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 sysdba
Enter 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)
    )
  )

<strong>PDBORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = pdborcl.localdomain)
    )
  )</strong>

Save and quit. Go to open this PDB again. Now you can access PDBORCL by service name.

[[email protected] admin]$ sqlplus [email protected] as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Tue Oct 28 00:08:52 2014

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Enter password: 

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL>

And the most importance is that now you are able to remotely connect this PDB!

Now you application can use this DB as well.

时间: 2024-08-25 06:01:44

Connect to a PDB of Oracle12c的相关文章

oracle12c创建用户等问题

一:前言 这几天我重新装了下电脑,然后自己有试着去装了下oracle11g,结果还是失败了然后我自己又去下载了最新的oracle12c,oracle12c中有两个用户sys和system,scott已经没有了,所以我自己就想创建一个自己的用户. 二:问题 我自己试了好多次都是报错“ORA-65096: 公用用户名或角色名无效”,最后百度才知道,写法是这样"create user c##xxx identified by xxx";因为现在创建的是cbd下的用户,cbd全称Contain

【12c】root container 和 pdb 的一些区别

  Where\what ? root pdb 备注 Control files and redo log files Y belongs to the CDB and not to a specific container Shared UNDO and default database temporary tablespace y Oracle-supplied metadata y Shared Oracle-supplied data y CDB views providing in

oracle12.2RAC之OGG安装配置(二)

本机到本机的配置: 源端       10.1.83.144:1521/SIBP_GSDY    HNSIB_GSDY目标端   10.1.83.144:1521/SIBP_GS         HNSIB_GS进程名规划 :OBB05 源端抽取进程及文件前缀:BG01_DY    DY 目标端恢复进程:OBR01 //环境变量设置#for oggexport GG_HOME=/ogg/data export PATH=$JAVA_HOME/bin:$GG_HOME:$PATH export L

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

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

Oracle11g数据库迁移到Oracle12C的PDB(使用impdp/expdp)

Oracle11g数据库迁移到Oracle12C的PDB(使用impdp/expdp)alter pluggable database hrdb close immediate;DROP PLUGGABLE DATABASE hrdb INCLUDING DATAFILES; --一.数据备份mkdir /oradata/dumpdir--创建目录create or replace directory exp_dir as '/oradata/dumpdir';--授权grant read,wr

Oracle12c多租户CDB 与 PDB 参数文件位置探讨、查询 CDB 与 PDB 不同值的参数

一. Oracle12c多租户CDB 与 PDB 参数文件位置 CDB的参数文件依然使用12c以前的SPIFLE,pdb的参数文件不会出现在SPFILE中,而是直接从CDB中继承,如果PDB中有privete Local parameter 会存在 CDB 的 PDB_SPFILE$字典表 中以con_id区别,当PDB UN-Plug时,PDB参数会写入PDB的XML文件中,当drop pluggable database后,pdb信息和PDB_SPFILE$记录也会被清除.再当PDB重新Pl

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、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---------------

ORACLE12C PDB创建默认表空间和用户语句

第一次接触到12C CDB和PDB数据库,且客户提供的是ORACLE一体机,只有访问权,费劲周折,今记录12C创建默认路径表空间语句和用户 --创建默认表空间: create tablespace tablesapce_name datafile size 500M   autoextend on next 100M; --创建用户空间: create user username identified by password default tablespace tablesapce_name