1.创建PDB
SQL> select name from v$datafile;
 
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/ora12c/system01.dbf
/u01/app/oracle/oradata/ora12c/pdbseed/system01.dbf
/u01/app/oracle/oradata/ora12c/sysaux01.dbf
/u01/app/oracle/oradata/ora12c/pdbseed/sysaux01.dbf
/u01/app/oracle/oradata/ora12c/undotbs01.dbf
/u01/app/oracle/oradata/ora12c/users01.dbf
/u01/app/oracle/oradata/ora12c/EMP/system01.dbf
/u01/app/oracle/oradata/ora12c/EMP/sysaux01.dbf
/u01/app/oracle/oradata/ora12c/EMP/EMP_users01.dbf
 
9 rows selected.
SQL> alter system set db_create_file_dest='/u01/app/oracle/oradata/ora12c/dsg';
 
System altered.
 
SQL> create pluggable database dsg admin user hxy identified by hxy roles=(connect);
 
Pluggable database created.
要先设置db_create_file_dest,否则创建PDB的时候报下面的错误:
SQL> create pluggable database dsg admin user hxy identified by hxy roles=(connect);
create pluggable database dsg admin user hxy identified by hxy roles=(connect)
                                                                             *
ERROR at line 1:
ORA-65016: FILE_NAME_CONVERT must be specified
查看
SQL> select con_id,name,open_mode from v$pdbs;
 
    CON_ID NAME                           OPEN_MODE
---------- ------------------------------ ----------
         2 PDB$SEED                       READ ONLY
         3 EMP                                READ WRITE
         4 DSG                                MOUNTED
启动DSG
SQL> alter pluggable database dsg open;
Pluggable database altered.
 
SQL> select con_id,name,open_mode from v$pdbs;
 
    CON_ID NAME                           OPEN_MODE
---------- ------------------------------ ----------
         2 PDB$SEED                       READ ONLY
         3 EMP                                READ WRITE
         4 DSG                                READ WRITE
 
2.(1)通过tnsname访问PDB数据库
例如:
首先需要启动监听,最好使用netca配置监听,配置完成后查看其状态为:
[oracle@db12 admin]$ lsnrctl status

LSNRCTL for Linux: Version 12.1.0.1. - Production on -AUG- ::

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db12)(PORT=)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.1.0.1. - Production
Start Date -AUG- ::
Uptime days hr. min. sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/12.1./network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/db12/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db12)(PORT=)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=db12)(PORT=))(Security=(my_wallet_directory=/u01/app/oracle/admin/db12/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "db12" has instance(s).
Instance "db12", status READY, has handler(s) for this service...
Service "db12XDB" has instance(s).
Instance "db12", status READY, has handler(s) for this service...
Service "emp" has instance(s).
Instance "db12", status READY, has handler(s) for this service...
The command completed successfully

如果使用手动配置监听器,pdb的监听不一定能启动,这点要注意!

查看当前数据库的PDB
SQL> select con_id,name,open_mode from v$pdbs;
    CON_ID NAME                           OPEN_MODE
---------- ------------------------------ ----------
         2 PDB$SEED                        READ ONLY
         3 EMP                                 READ WRITE
查看tnsnames.ora
EMP =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = EMP)
    )
  )
 
访问:
[oracle@localhost ~]$ sqlplus sys/oracle@emp as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Sat Jan 18 14:26:04 2014
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
 
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
 
SQL> show con_name con_id
CON_NAME
------------------------------
EMP
 
CON_ID
------------------------------
3
 
(2)使用EZCONNECT方式连接到数据库
SQL> conn sys/oracle@//localhost/dsg as sysdba
Connected.
 
SQL> show con_name con_id
 
CON_NAME
------------------------------
DSG
 
CON_ID
------------------------------
4 查看
SQL> select name from v$datafile;
 
NAME
------------------------------------------------------------------------------------------------------------------------
/u01/app/oracle/oradata/ora12c/undotbs01.dbf
/u01/app/oracle/oradata/ora12c/dsg/ORA12C/F039E431F9CE7170E0430100007F6A0D/datafile/o1_mf_system_9fn895qv_.dbf
/u01/app/oracle/oradata/ora12c/dsg/ORA12C/F039E431F9CE7170E0430100007F6A0D/datafile/o1_mf_sysaux_9fn89mpk_.dbf
有两个单独的数据文件system、sysaux和共享的undo表空间共享的全局数据文件
SQL> select name from v$tempfile;
 
NAME
------------------------------------------------------------------------------------------------------------------------
/u01/app/oracle/oradata/ora12c/dsg/ORA12C/F039E431F9CE7170E0430100007F6A0D/datafile/o1_mf_temp_9fn8bxy4_.dbf
有独立的临时文件
 
SQL> select name from v$controlfile;
 
NAME
------------------------------------------------------------------------------------------------------------------------
/u01/app/oracle/oradata/ora12c/control01.ctl
/u01/app/oracle/fast_recovery_area/ora12c/control02.ctl
控制文件是共享的
 
(3)在DBA等高级权限的用户下,通过alter命令进行会话级别的容器切换,访问不同容器下的对象
SQL> conn / as sysdba
Connected.
SQL> alter session set container=dsg;
Session altered.
 
SQL> show con_id con_name
CON_ID
------------------------------
4
CON_NAME
------------------------------
DSG
 
SQL> alter session set container=emp;
Session altered.
 
SQL> show con_id con_name
CON_ID
------------------------------
3
CON_NAME
------------------------------
EMP
 
五,关闭PDB
 
(1)切换到PDB
SQL> alter session set container=dsg;
Session altered.
 
SQL> show con_id con_name
CON_ID
------------------------------
4
CON_NAME
------------------------------
DSG
 
SQL> shutdown immediate
Pluggable Database closed.
(2)在具有sys权限的用户执行
SQL> alter pluggable database emp close;
Pluggable database altered.
 
六,删除PDB
SQL> select con_id,name,open_mode from v$pdbs;
 
    CON_ID NAME                           OPEN_MODE
---------- ------------------------------ ----------
         2 PDB$SEED                       READ ONLY
         3 EMP                            MOUNTED
         4 DSG                            READ WRITE
 
SQL> drop pluggable database dsg including datafiles;
drop pluggable database dsg including datafiles
*
ERROR at line 1:
ORA-65025: Pluggable database DSG is not closed on all instances.
必须让PDB处于关闭状态才能删除PDB
 
SQL> alter pluggable database dsg close;
Pluggable database altered.
 
SQL> drop pluggable database dsg including datafiles;
Pluggable database dropped.
 
查看产生的alert日志:
把相应的数据文件全部删除
在OS中查看:

2.oracle 12c 创建-访问-关闭-删除PDB的更多相关文章

  1. oracle 12c 创建PDB用户即Local User (PDB与CDB)

    Oracle 12C用户创建与表空间分配  数据库安装完成后,首先用系统用户链接数据库容器(CDB), 在数据库容器(CDB)中创建表空间‘imei’ SQL>create tablespace ...

  2. ORACLE 12C新特性——CDB与PDB

    Oracle 12C引入了CDB与PDB的新特性,在ORACLE 12C数据库引入的多租用户环境(Multitenant Environment)中,允许一个数据库容器(CDB)承载多个可插拔数据库( ...

  3. oracle 12c创建可插拔数据库(PDB)与用户详解

    前言 由于oracle 12c使用了CDB-PDB架构,类似于docker,在container-db内可以加载多个pluggable-db,因此安装后需要额外配置才能使用. 一.修改listener ...

  4. oracle 12c创建可插拔数据库(PDB)及用户

    由于oracle 12c使用了CDB-PDB架构,类似于docker,在container-db内可以加载多个pluggable-db,因此安装后需要额外配置才能使用. 一.修改listener.or ...

  5. Oracle 12c创建用户时出现“ORA-65096: invalid common user or role name”的错误

    这篇文章主要介绍CDB和PDB的基本管理,资料来源oracle官方. 基本概念: Multitenant Environment:多租户环境 CDB(Container Database):数据库容器 ...

  6. Oracle 12c 创建新的数据库实例、用户

    前提:安装好了Oracle 12c数据库,已有一个数据库实例xe,登录用户/密码:system/oralce 我用的是docker安装的Oracle 12c的实例: docker run --name ...

  7. Oracle 12C 创建用户连接pdb

    测试环境: C:\ora12c\product\12.1.0\dbhome_1\BIN>sqlplus.exe /nolog SQL*Plus: Release 12.1.0.1.0 Produ ...

  8. Oracle 12c 创建用户

    本文转载自 http://blog.itpub.net/29047826/viewspace-1453577/,侵删.   12c推出了可插拔库,管理用户也分为两种:本地用户和公用用户.本地用户是指在 ...

  9. Oracle 12c 多租户 CDB 与 PDB 级别 expdb 与 impdb(表、用户、全库)

    Oracle 数据库 12 c 多租户下,如何在容器数据库 (CDB) 和可插拔数据库 (PDB) 中使用 expdb 与 impdp (数据泵) 呢? 我们一起探讨下PDB 下进行表级,用户级别,全 ...

随机推荐

  1. git-添加公钥

    安装完git后,打开开git bush 输入以下命令 git config --global user.name "Your Name" git config --global u ...

  2. Java研发方向如何准备BAT技术面试答案(上)

    http://blog.csdn.net/q979392157/article/details/52164319 阿里面试题总结 http://blog.csdn.net/q979392157/art ...

  3. BZOJ 1861: [Zjoi2006]Book 书架

    1861: [Zjoi2006]Book 书架 Time Limit: 4 Sec  Memory Limit: 64 MBSubmit: 1290  Solved: 740[Submit][Stat ...

  4. 正则表达式解析url参数

    解析url参数正则:(?<=\?|&)[\w\={}\\\\,-:'\s'""]*(?=[^#\s]|) 意思是(?<=\?|&) 从?或&符号 ...

  5. Sql简单封装

    public class SqlHelper { public static string SqlConnectionStr = ConfigurationManager.ConnectionStri ...

  6. <<< Java生成Md5

    package cn.sevennight.test; import java.security.MessageDigest; public class md5{ public static Stri ...

  7. linux下centos的网络连接

  8. php 做数学运算时结果为0的原因

    php是一种弱类型的脚本语言,一般情况下字符串型的数字可以直接参与运算. 但是当字符串开头是实体空格的时候系统会默认字符串等于0. 此问题比较隐蔽,在此记录下

  9. 2015.4.24 移动端,chrome不兼容或无法运行的一些具体问题

    1.table内input,把它的边框和focus边框都变成透明,在ff可行,但是chrome会有样式,怎么解决? 解决方法:border:none;outline:0; 2.如下代码,css3动画在 ...

  10. 用类方法------>快速创建一个autorelease的对象,在封装的类方法内部

    在封装的类方法内部,也就是+ (id)personWithName:(NSString *)name andAge:(int)age内部: 创建了一个person对象,并且创建了一个person*类型 ...