CDB和PDB基本管理
CDB和PDB基本管理
这篇文章主要介绍CDB和PDB的基本管理,资料来源oracle官方。
基本概念:
Multitenant Environment:多租户环境
CDB(Container Database):数据库容器
PD(Pluggable Database):可插拔数据库
CDB与PDB关系图
环境信息如下:
DB version:12.0.1
ORACLE_HOME: /u01/app/oracle/product/12.1.0
TNS Listener port: 1521
Container databases:
SID: cdbtest
1、查看数据库是否为CDB
SYS@cdbtest> select name, decode(cdb, 'YES', 'Multitenant Option enabled', 'Regular 12c Database: ') "Multitenant Option" , open_mode, con_id from v$database;
NAME Multitenant Option OPEN_MODE CON_ID
--------- -------------------------- -------------------- ----------
CDBTEST Multitenant Option enabled READ WRITE 0
2、连接到CDB
2.1、简易方式连接
首先查看服务状态:
$lsnrctl service
LSNRCTL for Linux: Version 12.1.0.1.0 - Production on 14-APR-2014 20:54:47
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
Services Summary...
Service "cdbtest.oracle.com" has 1 instance(s).
Instance "cdbtest", status READY, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:2 refused:0 state:ready
LOCAL SERVER
Service "cdbtestXDB.oracle.com" has 1 instance(s).
Instance "cdbtest", status READY, has 1 handler(s) for this service...
Handler(s):
"D000" established:0 refused:0 current:0 max:1022 state:ready
DISPATCHER <machine: localhost.localdomain, pid: 2681>
(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=60617))
Service "pdb1.oracle.com" has 1 instance(s).
Instance "cdbtest", status READY, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:2 refused:0 state:ready
LOCAL SERVER
Service "pdb3_his.oracle.com" has 1 instance(s).
Instance "cdbtest", status READY, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:2 refused:0 state:ready
LOCAL SERVER
The command completed successfully
可以看到上面有cdbtest.oracle.com ,pdb1.oracle.com,pdb3_his.oracle.com 这3个服务,下面使用cdbtest.oracle.com来连接
$sqlplus sys/password@localhost:1521/cdbtest.oracle.com as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Mon Apr 14 20:53:22 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
SYS@localhost:1521/cdbtest.oracle.com>
2.2、使用net service方式连接
需要在$ORACLE_HOME/network/admin/tnsnames.ora中进行配置,本例配置如下:
oracle*cdbtest*/u01/app/oracle/product/12.1.0/db_1/network/admin>$more tnsnames.ora
cdbtest=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))
(CONNECT_DATA=
(SID=cdbtest)
(SERVICE_NAME=cdbtest.oracle.com)
(INSTANCE_NAME=cdbtest)))
使用cdbtest来连接:
$sqlplus sys/password@cdbtest as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Mon Apr 14 20:57:30 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
SYS@cdbtest>
2.3、使用os认证的方式连接
oracle*cdbtest*/home/oracle>$sqlplus / as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Mon Apr 14 20:59:13 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
SYS@cdbtest>
2.4、查看容器名称和ID
SYS@cdbtest> show con_name ;
CON_NAME
------------------------------
CDB$ROOT
SYS@cdbtest> show con_id ;
CON_ID
------------------------------
1
3、查看root和PDBS的服务信息
SYS@cdbtest> select name ,con_id from v$active_services order by 1 ;
NAME CON_ID
---------------------------------------------------------------- ----------
SYS$BACKGROUND 1
SYS$USERS 1
cdbtest.oracle.com 1
cdbtestXDB 1
pdb1.oracle.com 3
pdb3_his.oracle.com 4
6 rows selected.
4、连接到PDBs
使用简单连接方式
连接到pdb1.oracle.com:
$sqlplus sys/password@localhost:1521/pdb1.oracle.com as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Mon Apr 14 21:04:22 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
SYS@localhost:1521/pdb1.oracle.com>
连接到pdb3_his.oracle.com:
$sqlplus sys/password@localhost:1521/pdb3_his.oracle.com as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Mon Apr 14 21:04:42 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
SYS@localhost:1521/pdb3_his.oracle.com>
5、创建一个新的PDB
从seed PDB创建一个PDB(每个CDB有一个PDB template,名为PDB$Seed)
准备工作:
创建一个操作系统的目录用来存放新创建的PDB数据库的数据文件和临时文件:
mkdir -p /u01/app/oracle/oradata/cdbtest/pdb4
5.1、创建PDB
$sqlplus / as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Mon Apr 14 21:12:11 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
SYS@cdbtest> create pluggable database pdb4
2 admin user odb4_admin identified by password
3 roles=(dba)
4 file_name_convert=('/u01/app/oracle/oradata/cdbtest/pdbseed','/u01/app/oracle/oradata/cdbtest/pdb4') ;
Pluggable database created.
5.2、验证
SYS@cdbtest> select pdb_name,status from cdb_pdbs ;
PDB_NAME STATUS
------------------------------ -------------
PDB1 NORMAL
PDB$SEED NORMAL
PDB3_HIS NORMAL
PDB4 NEW
如果status状态为NEED SYNC,要运行DBMS_PDB.SYNC_PDB将状态改变
SYS@cdbtest> select name,open_mode from v$pdbs ;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDB1 READ WRITE
PDB3_HIS READ WRITE
PDB4 MOUNTED
SYS@cdbtest> select name ,con_id from v$active_services order by 1 ;
NAME CON_ID
---------------------------------------------------------------- ----------
SYS$BACKGROUND 1
SYS$USERS 1
cdbtest.oracle.com 1
cdbtestXDB 1
pdb1.oracle.com 3
pdb3_his.oracle.com 4
pdb4.oracle.com 5
5.3、列出数据文件
SYS@cdbtest> select name from v$datafile where con_id=5 ;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/cdbtest/pdb4/system01.dbf
/u01/app/oracle/oradata/cdbtest/pdb4/sysaux01.dbf
6、打开和关闭PDBs
关闭
SYS@cdbtest> shutdown
Database closed.
Database dismounted.
ORACLE instance shut down.
打开
SYS@cdbtest> startup
ORACLE instance started.
Total System Global Area 584568832 bytes
Fixed Size 2290992 bytes
Variable Size 461376208 bytes
Database Buffers 117440512 bytes
Redo Buffers 3461120 bytes
Database mounted.
Database opened.
查看状态
SYS@cdbtest> select name ,open_mode from v$pdbs ;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDB1 MOUNTED
PDB3_HIS MOUNTED
PDB4 MOUNTED
启动PDB4
SYS@cdbtest> alter pluggable database pdb4 open ;
Pluggable database altered.
SYS@cdbtest> select name ,open_mode from v$pdbs ;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDB1 MOUNTED
PDB3_HIS MOUNTED
PDB4 READ WRITE
启动所有的PDBs
SYS@cdbtest> alter pluggable database all open ;
Pluggable database altered.
SYS@cdbtest> select name ,open_mode from v$pdbs ;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDB1 READ WRITE
PDB3_HIS READ WRITE
PDB4 READ WRITE
关闭PDB1
SYS@cdbtest> alter pluggable database pdb1 close immediate ;
Pluggable database altered.
SYS@cdbtest> select name ,open_mode from v$pdbs ;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDB1 MOUNTED
PDB3_HIS READ WRITE
PDB4 READ WRITE
关闭所有的PDBs
SYS@cdbtest> alter pluggable database all close immediate ;
Pluggable database altered.
SYS@cdbtest> select name ,open_mode from v$pdbs ;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDB1 MOUNTED
PDB3_HIS MOUNTED
PDB4 MOUNTED
从上面的操作中可以看到数据库启动的时候所有的PDBs的状态为MOUNTED,在实际应用可以考虑增加如下的触发器使所有的PDBs都处于打开状态。以下为验证过程:
SYS@cdbtest> create or replace trigger sys.after_startup after startup on database
2 begin
3 execute immediate 'alter pluggable database all open ' ;
4 end after_startup ;
5 /
Trigger created.
SYS@cdbtest> shutdown immediate ;
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@cdbtest> startup
ORACLE instance started.
Total System Global Area 584568832 bytes
Fixed Size 2290992 bytes
Variable Size 461376208 bytes
Database Buffers 117440512 bytes
Redo Buffers 3461120 bytes
Database mounted.
Database opened.
SYS@cdbtest> select name ,open_mode from v$pdbs ;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDB1 READ WRITE
PDB3_HIS READ WRITE
PDB4 READ WRITE
5.4、rename PDB
rename pdb时pdb需要处于open restricted状态。
SYS@cdbtest> alter pluggable database pdb4 close immediate ;
Pluggable database altered.
SYS@cdbtest> alter pluggable database pdb4 open restricted ;
Pluggable database altered.
SYS@cdbtest> select name ,restricted from v$pdbs ;
NAME RES
------------------------------ ---
PDB$SEED NO
PDB1 NO
PDB3_HIS NO
PDB4 YES
SYS@cdbtest> conn sys/password@localhost:1521/pdb4.oracle.com
ERROR:
ORA-28009: connection as SYS should be as SYSDBA or SYSOPER
Warning: You are no longer connected to ORACLE.
连接到PDB4
SYS@cdbtest> conn sys/password@localhost:1521/pdb4.oracle.com as sysdba
Connected.
SYS@localhost:1521/pdb4.oracle.com> alter pluggable database pdb4 rename global_name to pdb4_his ;
Pluggable database altered.
SYS@localhost:1521/pdb4.oracle.com> alter pluggable database close immediate ;
Pluggable database altered.
SYS@localhost:1521/pdb4.oracle.com> select name ,open_mode from v$pdbs ;
NAME OPEN_MODE
------------------------------ ----------
PDB4_HIS MOUNTED
SYS@localhost:1521/pdb4.oracle.com> conn / as sysdba
Connected.
SYS@cdbtest> alter pluggable database close immediate ;
alter pluggable database close immediate
*
ERROR at line 1:
ORA-65000: missing or invalid pluggable database name
SYS@cdbtest> alter pluggable database all close immediate ;
Pluggable database altered.
SYS@cdbtest> alter pluggable database all open ;
Pluggable database altered.
SYS@cdbtest> select name ,open_mode from v$pdbs ;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDB1 READ WRITE
PDB3_HIS READ WRITE
PDB4_HIS READ WRITE
6、存储管理
查看数据文件信息
SYS@cdbtest> conn / as sysdba
Connected.
SYS@cdbtest> select tablespace_name,con_id from cdb_tablespaces where con_id =1 ;
TABLESPACE_NAME CON_ID
------------------------------ ----------
SYSTEM 1
SYSAUX 1
UNDOTBS1 1
TEMP 1
USERS 1
CDATA 1
6 rows selected.
SYS@cdbtest> col file_name for a50
SYS@cdbtest> select file_name,con_id from cdb_data_files where con_id =1 ;
FILE_NAME CON_ID
-------------------------------------------------- ----------
/u01/app/oracle/oradata/cdbtest/system01.dbf 1
/u01/app/oracle/oradata/cdbtest/sysaux01.dbf 1
/u01/app/oracle/oradata/cdbtest/undotbs01.dbf 1
/u01/app/oracle/oradata/cdbtest/users01.dbf 1
/u01/app/oracle/oradata/cdbtest/cdata01.dbf 1
在root中创建持久表空间
SYS@cdbtest> create tablespace cdata01 datafile '/u01/app/oracle/oradata/cdbtest/cdata0101.dbf' size 10m;
Tablespace created.
SYS@cdbtest> select tablespace_name ,con_id from cdb_tablespaces order by con_id ;
TABLESPACE_NAME CON_ID
------------------------------ ----------
SYSTEM 1
CDATA01 1
CDATA 1
SYSAUX 1
TEMP 1
UNDOTBS1 1
USERS 1
SYSTEM 2
SYSAUX 2
TEMP 2
SYSTEM 3
TABLESPACE_NAME CON_ID
------------------------------ ----------
EXAMPLE 3
SYSAUX 3
TEMP 3
USERS 3
SYSTEM 4
TEMP_PDB3 4
SYSAUX 4
TEMP 4
LDATA 4
SYSTEM 5
TEMP 5
TABLESPACE_NAME CON_ID
------------------------------ ----------
SYSAUX 5
23 rows selected.
SYS@cdbtest> select file_name,con_id from cdb_data_files order by con_id ;
FILE_NAME CON_ID
-------------------------------------------------- ----------
/u01/app/oracle/oradata/cdbtest/system01.dbf 1
/u01/app/oracle/oradata/cdbtest/cdata0101.dbf 1
/u01/app/oracle/oradata/cdbtest/sysaux01.dbf 1
/u01/app/oracle/oradata/cdbtest/users01.dbf 1
/u01/app/oracle/oradata/cdbtest/undotbs01.dbf 1
/u01/app/oracle/oradata/cdbtest/cdata01.dbf 1
/u01/app/oracle/oradata/cdbtest/pdbseed/sysaux01.dbf 2
/u01/app/oracle/oradata/cdbtest/pdbseed/system01.dbf 2
FILE_NAME CON_ID
-------------------------------------------------- ----------
/u01/app/oracle/oradata/cdbtest/pdb1/system01.dbf 3
/u01/app/oracle/oradata/cdbtest/pdb1/sysaux01.dbf 3
/u01/app/oracle/oradata/cdbtest/pdb1/SAMPLE_SCHEMA 3
_users01.dbf
/u01/app/oracle/oradata/cdbtest/pdb1/example01.dbf 3
/u01/app/oracle/oradata/cdbtest/pdb3/system01.dbf 4
/u01/app/oracle/oradata/cdbtest/pdb3/sysaux01.dbf 4
/u01/app/oracle/oradata/cdbtest/pdb3/ldata01.dbf 4
/u01/app/oracle/oradata/cdbtest/pdb4/sysaux01.dbf 5
FILE_NAME CON_ID
-------------------------------------------------- ----------
/u01/app/oracle/oradata/cdbtest/pdb4/system01.dbf 5
17 rows selected.
在root中创建临时表空间
SYS@cdbtest> create temporary tablespace temp_root_01 tempfile '/u01/app/oracle/oradata/cdbtest/temproot0101.dbf' size 10m ;
Tablespace created.
SYS@cdbtest> select tablespace_name ,con_id from cdb_tablespaces where contents='TEMPORARY' and con_id=1 ;
TABLESPACE_NAME CON_ID
------------------------------ ----------
TEMP 1
TEMP_ROOT_01 1
SYS@cdbtest> select file_name ,con_id from cdb_temp_files where con_id =1 ;
FILE_NAME CON_ID
-------------------------------------------------- ----------
/u01/app/oracle/oradata/cdbtest/temp01.dbf 1
/u01/app/oracle/oradata/cdbtest/temproot0101.dbf 1
SYS@cdbtest>
SYS@cdbtest> conn system/password@localhost:1521/pdb4_his.oracle.com
Connected.
在pdb4_his中创建持久表空间
SYSTEM@localhost:1521/pdb4_his.oracle.com> create tablespace ldata datafile '/u01/app/oracle/oradata/cdbtest/pdb4/ldata01.dbf' size 10m ;
Tablespace created.
SYSTEM@localhost:1521/pdb4_his.oracle.com> select tablespace_name,con_id from cdb_tablespaces order by con_id ;
TABLESPACE_NAME CON_ID
------------------------------ ----------
SYSTEM 5
SYSAUX 5
TEMP 5
LDATA 5
SYSTEM@localhost:1521/pdb4_his.oracle.com> select file_name from dba_data_files ;
FILE_NAME
--------------------------------------------------
/u01/app/oracle/oradata/cdbtest/pdb4/system01.dbf
/u01/app/oracle/oradata/cdbtest/pdb4/sysaux01.dbf
/u01/app/oracle/oradata/cdbtest/pdb4/ldata01.dbf
在pdb4_his中创建临时表空间
SYSTEM@localhost:1521/pdb4_his.oracle.com> create temporary tablespace temp_pdb4 tempfile '/u01/app/oracle/oradata/cdbtest/pdb4/temppdb401.dbf' size 10m ;
Tablespace created.
SYSTEM@localhost:1521/pdb4_his.oracle.com> select tablespace_name,con_id from cdb_tablespaces where contents='TEMPORYARY';
no rows selected
SYSTEM@localhost:1521/pdb4_his.oracle.com> select tablespace_name,con_id from cdb_tablespaces where contents='TEMPORARY';
TABLESPACE_NAME CON_ID
------------------------------ ----------
TEMP 5
TEMP_PDB4 5
SYSTEM@localhost:1521/pdb4_his.oracle.com> select file_name from dba_temp_files
2 ;
FILE_NAME
--------------------------------------------------
/u01/app/oracle/oradata/cdbtest/pdb4/pdbseed_temp01.dbf
/u01/app/oracle/oradata/cdbtest/pdb4/temppdb401.dbf
7、安全管理
7.1、用户管理
SYSTEM@localhost:1521/pdb4_his.oracle.com> conn / as sysdba
Connected.
在root中创建用户c##1,用户名需要以c##开头,在root中创建的用户会复制到所有的pdbs中,除了seed pdb。
SYS@cdbtest> create user c##2 identified by password container=all ;
User created.
SYS@cdbtest> select username,common,con_id from cdb_users where username like 'C##%' ;
USERNAME COM CON_ID
------------------------------ --- ----------
C##1 YES 4
C##2 YES 4
C##1 YES 3
C##2 YES 3
C##1 YES 1
C##2 YES 1
C##1 YES 5
C##2 YES 5
从上面的输出中可以看到在每个PDB中都有用户C##1,除了pdb seed。
尝试登录
SYS@cdbtest> conn c##2/password@localhost:1521/pdb4_his.oracle.com
ERROR:
ORA-01045: user C##2 lacks CREATE SESSION privilege; logon denied
Warning: You are no longer connected to ORACLE.
在pdb中创建用户
SYS@cdbtest> conn system/password@localhost:1521/pdb4_his.oracle.com
Connected.
SYSTEM@localhost:1521/pdb4_his.oracle.com> create user hr identified by password ;
User created.
SYSTEM@localhost:1521/pdb4_his.oracle.com> select username,common,con_id from cdb_users where username like 'HR';
USERNAME COM CON_ID
------------------------------ --- ----------
HR NO 5
尝试登录
SYSTEM@localhost:1521/pdb4_his.oracle.com> conn hr/password@localhost:1521/pdb4_his.oracle.com
ERROR:
ORA-01045: user HR lacks CREATE SESSION privilege; logon denied
Warning: You are no longer connected to ORACLE.
SYSTEM@localhost:1521/pdb4_his.oracle.com> conn system/password@localhost:1521/pdb4_his.oracle.com
Connected.
单独在pdb中赋予create session权限
SYSTEM@localhost:1521/pdb4_his.oracle.com> grant create session to c##2 ;
Grant succeeded.
再次登录pdb4
SYSTEM@localhost:1521/pdb4_his.oracle.com> conn c##2/password@localhost:1521/pdb4_his.oracle.com
Connected.
测试登录pdb3
C##2@localhost:1521/pdb4_his.oracle.com> conn c##2/password@localhost:1521/pdb3_his.oracle.com
ERROR:
ORA-01045: user C##2 lacks CREATE SESSION privilege; logon denied
Warning: You are no longer connected to ORACLE.
C##2@localhost:1521/pdb4_his.oracle.com> grant create session to hr ;
SP2-0640: Not connected
C##2@localhost:1521/pdb4_his.oracle.com> conn system/password@localhost:1521/pdb4_his.oracle.com
Connected.
SYSTEM@localhost:1521/pdb4_his.oracle.com> grant create session to hr ;
Grant succeeded.
SYSTEM@localhost:1521/pdb4_his.oracle.com> conn hr/password@localhost:1521/pdb4_his.oracle.com
Connected.
在所有的pdbs给用户c##2赋予create session权限
HR@localhost:1521/pdb4_his.oracle.com> conn / as sysdba
Connected.
SYS@cdbtest> grant create session to c##2 container=all ;
Grant succeeded.
SYS@cdbtest> conn c##2/password@localhost:1521/pdb1.oracle.com
Connected.
7.2、角色管理
C##2@localhost:1521/pdb1.oracle.com> conn / as sysdba
Connected.
SYS@cdbtest> create role c##r2 container=all ;
Role created.
SYS@cdbtest> select role,common,con_id from cdb_roles where role='C##R2' ;
ROLE COM CON_ID
---------- --- ----------
C##R2 YES 5
C##R2 YES 4
C##R2 YES 3
C##R2 YES 1
从上面的输出可以看到每个pdb(除了seed)都有role C##R2
SYS@cdbtest> conn system/password@localhost:1521/pdb4_his.oracle.com
Connected.
单独在pdb中创建role
SYSTEM@localhost:1521/pdb4_his.oracle.com> create role hr_manager ;
Role created.
SYSTEM@localhost:1521/pdb4_his.oracle.com> select role,common,con_id from cdb_roles where role='HR_MANAGER';
ROLE COM CON_ID
---------- --- ----------
HR_MANAGER NO 5
SYSTEM@localhost:1521/pdb4_his.oracle.com> create role c##r2 container=all ;
create role c##r2 container=all
*
ERROR at line 1:
ORA-65050: Common DDLs only allowed in CDB$ROOT
在root中给角色授予权限
SYSTEM@localhost:1521/pdb4_his.oracle.com> conn / as sysdba
Connected.
SYS@cdbtest> grant create session to c##2 container=all ;
Grant succeeded.
SYS@cdbtest> select grantee,privilege,common,con_id from cdb_sys_privs
2 where privilege='CREATE SESSION' and grantee='C##2';
GRANTEE PRIVILEGE COM CON_ID
------------------------------ ---------------------------------------- --- ----------
C##2 CREATE SESSION NO 5
C##2 CREATE SESSION YES 5
C##2 CREATE SESSION YES 4
C##2 CREATE SESSION YES 3
C##2 CREATE SESSION YES 1
SYS@cdbtest> conn c##2/password@localhost:1521/pdb4_his.oracle.com
Connected.
C##2@localhost:1521/pdb4_his.oracle.com> select * from session_privs ;
PRIVILEGE
----------------------------------------
CREATE SESSION
C##2@localhost:1521/pdb4_his.oracle.com> conn c##2/password@localhost:121/pdb4_his.oracle.com
ERROR:
ORA-12541: TNS:no listener
Warning: You are no longer connected to ORACLE.
C##2@localhost:1521/pdb4_his.oracle.com> conn c##2/password@localhost:1521/pdb4_his.oracle.com
Connected.
C##2@localhost:1521/pdb4_his.oracle.com> select * from session_privs ;
PRIVILEGE
----------------------------------------
CREATE SESSION
C##2@localhost:1521/pdb4_his.oracle.com> connect system/password@localhost:1521/pdb4_his.oracle.com
Connected.
SYSTEM@localhost:1521/pdb4_his.oracle.com> grant create session to hr container=all ;
grant create session to hr container=all
*
ERROR at line 1:
ORA-65030: one may not grant a Common Privilege to a Local User or Role
SYSTEM@localhost:1521/pdb4_his.oracle.com> grant create session to hr ;
Grant succeeded.
SYSTEM@localhost:1521/pdb4_his.oracle.com> select grantee,privilege,common,con_id from cdb_sys_privs
2 where privilege='CREATE SESSION' and grantee='HR' ;
GRANTEE PRIVILEGE COM CON_ID
------------------------------ ---------------------------------------- --- ----------
HR CREATE SESSION NO 5
8、PDBs删除
SYSTEM@localhost:1521/pdb4_his.oracle.com> conn / as sysdba
Connected.
SYS@cdbtest>
SYS@cdbtest> alter pluggable database all close immediate ;
Pluggable database altered.
SYS@cdbtest> select name ,open_mode from v$pdbs ;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDB1 MOUNTED
PDB3_HIS MOUNTED
PDB4_HIS MOUNTED
SYS@cdbtest> drop pluggable database pdb4_his including datafile ;
drop pluggable database pdb4_his including datafile
*
ERROR at line 1:
ORA-02000: missing DATAFILES keyword
SYS@cdbtest> drop pluggable database pdb4_his including datafiles ;
Pluggable database dropped.
SYS@cdbtest> select name ,open_mode from v$pdbs ;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDB1 MOUNTED
PDB3_HIS MOUNTED
SYS@cdbtest>
SYS@cdbtest> drop user c##1;
User dropped.
SYS@cdbtest> drop user c##2;
User dropped.
SYS@cdbtest> drop role c##r1 ;
Role dropped.
SYS@cdbtest> drop role c##r2 ;
Role dropped.
SYS@cdbtest> drop tablespace cdata01 including contents ;
Tablespace dropped.
SYS@cdbtest> drop tablespace cdata including contents ;
Tablespace dropped.
SYS@cdbtest> drop tablespace temp_root_01 including contents ;
Tablespace dropped.
CDB和PDB基本管理的更多相关文章
- Oracle 12C CDB、PDB常用管理命令
Oracle 12C CDB.PDB常用管理命令 --查看PDB信息(在CDB模式下) show pdbs --查看所有pdbselect name,open_mode from v$pdbs; ...
- CDB和PDB的创建、连接、启动、关闭
一.CDB和PDB基本管理 基本概念: Multitenant Environment:多租户环境 CDB(Container Database):数据库容器 PD(Pluggable Databas ...
- 12c可插拔数据库CDB与PDB管理总结
12c可插拔数据库CDB与PDB管理总结 创建pdb1.直接创建 CREATE PLUGGABLE DATABASE pdb2 ADMIN USER boswll IDENTIFIED BY orac ...
- 浅谈Oracle12c 数据库、用户、CDB与PDB之间的关系
名词介绍: 数据库:数据库(Database)是按照数据结构来组织.存储和管理数据的仓库,它产生 于距今六十多年前,随着信息技术和市场的发展,特别是二十世纪九十年代以 后,数据管理不再仅仅是存储和管理 ...
- oracle 12C的新特性-CDB和PDB
1.前言 CDB与PDB是Oracle 12C引入的新特性,在ORACLE 12C数据库引入的多租用户环境(Multitenant Environment)中,允许一个数据库容器(CDB)承载多个可插 ...
- ORACLE 12C新特性——CDB与PDB
Oracle 12C引入了CDB与PDB的新特性,在ORACLE 12C数据库引入的多租用户环境(Multitenant Environment)中,允许一个数据库容器(CDB)承载多个可插拔数据库( ...
- Oracle12c CDB和PDB数据库的启动与关闭说明
Oracle 12c中,增加了可插接数据库的概念,即PDB,允许一个数据库容器(CDB)承载多个可插拔数据库(PDB). CDB全称为Container Database,中文翻译为数据库容器,PDB ...
- 转 12C 连接CDB和PDB
来源:David Dai -- Focus on Oracle 连接到CDB 和普通实例一样的连接. 指定ORACLE_SID 以后可以使用OS认证,也可以使用密码进行连接. [oracle@Ora1 ...
- Oracle12c多租户CDB 与 PDB 参数文件位置探讨、查询 CDB 与 PDB 不同值的参数
一. Oracle12c多租户CDB 与 PDB 参数文件位置CDB的参数文件依然使用12c以前的SPIFLE,pdb的参数文件不会出现在SPFILE中,而是直接从CDB中继承,如果PDB中有priv ...
随机推荐
- updmap-sys failed. Output has been stored in
Ubuntu 12.04升级到Ubuntu 12.04lts的时候,出现错误: Do you want to continue? [Y/n] ySetting up tex-common (4.04) ...
- Struts2笔记——ONGL表达式语言
OGNL是ObjectGraphic Navigation Language(对象图导航语言)的缩写,它是一个开源项目. Struts 2框架使用OGNL作为默认的表达式语言. ----------- ...
- iOS 库文件制作
一.静态库和动态库的介绍 一.什么是库? 库是共享程序代码的方式,一般分为静态库和动态库. 二.静态库与动态库的区别? 静态库:链接时完整地拷贝至可执行文件中,被多次使用就有多份冗余拷贝. 动态库:链 ...
- logstash_agent.conf 语法注意事项
编写配置文件时要注意语法,如新版本的logstash对参数host变更为hosts,去除了port参数等. [root@localhost logstash]# cat logstash_agent. ...
- (译) Angular运行原理揭秘 Part 1
当你用AngularJS写的应用越多, 你会越发的觉得它相当神奇. 之前我用AngularJS实现了相当多酷炫的效果, 所以我决定去看看它的源码, 我想这样也许我能知道它的原理. 下面是我从源码中找到 ...
- HDU 4622 Reincarnation 后缀自动机
模板来源:http://blog.csdn.net/zkfzkfzkfzkfzkfzkfzk/article/details/9669747 解法参考:http://blog.csdn.net/dyx ...
- HDU 4617 Weapon 三维计算几何
题意:给你一些无限长的圆柱,知道圆柱轴心直线(根据他给的三个点确定的平面求法向量即可)与半径,判断是否有圆柱相交.如果没有,输出柱面最小距离. 一共只有30个圆柱,直接暴力一下就行. 判相交/相切:空 ...
- env1
给新手参考的Cadence Allegro快捷键 原文链接:http://www.eda365.com/thread-30935-1-1.html 发上我的快捷键给新手参考,我也是在LULU给我的EN ...
- pyhton与json,Xml
对简单数据类型的encoding 和 decoding: 使用简单的json.dumps方法对简单数据类型进行编码,例如: 1 2 3 4 5 6 import json obj = [[1,2, ...
- leetcode Database3(Nth Highest Salary<—>Consecutive Numbers<—>Department Highest Salary)
一.Nth Highest Salary Write a SQL query to get the nth highest salary from the Employee table. +----+ ...