音效素材网提供各类素材,打造精品素材网站!

站内导航 站长工具 投稿中心 手机访问

音效素材

ORACLE 12C PDB 维护基础知识介绍
日期:2016-09-16 21:50:37   来源:脚本之家

先说基本用法:
先按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       0
PL/SQL Release 12.1.0.1.0 - Production                          0
CORE  12.1.0.1.0   Production                            0
TNS for Linux: Version 12.1.0.1.0 - Production                      0
NLSRTL Version 12.1.0.1.0 - Production                          0

启动关闭pdb

SQL> startup
ORACLE instance started.
 
Total System Global Area 597098496 bytes
Fixed Size         2291072 bytes
Variable Size       272632448 bytes
Database Buffers     314572800 bytes
Redo Buffers        7602176 bytes
Database 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              MOUNTED
 
SQL> 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              MOUNTED
 
SQL> 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              MOUNTED
 
SQL> 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 WRITE
 
SQL> 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              MOUNTED
 
SQL> alter session set container=pdb1;
 
Session altered.
 
SQL> startup
Pluggable 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 status
 
LSNRCTL for Linux: Version 12.1.0.1.0 - Production on 12-MAY-2013 08:07:02
 
Copyright (c) 1991, 2013, Oracle. All rights reserved.
 
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xifenfei)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias           LISTENER
Version          TNSLSNR for Linux: Version 12.1.0.1.0 - Production
Start Date        11-MAY-2013 18:30:54
Uptime          0 days 13 hr. 36 min. 8 sec
Trace Level        off
Security         ON: Local OS Authentication
SNMP           OFF
Listener Parameter File  /u01/app/grid/product/12.1/network/admin/listener.ora
Listener Log File     /u01/app/grid/diag/tnslsnr/xifenfei/listener/alert/log.xml
Listening 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 pdb1
 
TNS Ping Utility for Linux: Version 12.1.0.1.0 - Production on 12-MAY-2013 08:07:09
 
Copyright (c) 1997, 2013, Oracle. All rights reserved.
 
Used parameter files:
 
 
Used TNSNAMES adapter to resolve the alias
Attempting 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 sysdba
 
SQL*Plus: Release 12.1.0.1.0 Production on Sun May 12 08:08:02 2013
 
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, Automatic Storage Management, OLAP, Advanced Analytics
and Real Application Testing options
 
SQL> show con_name;
 
CON_NAME
------------------------------
PDB1
 
 
[oracle@xifenfei ~]$ sqlplus / as sysdba
 
SQL*Plus: Release 12.1.0.1.0 Production on Sun May 12 08:09:14 2013
 
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, Automatic Storage Management, OLAP, Advanced Analytics
and Real Application Testing options
 
SQL> 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$ROOT
 
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              MOUNTED
 
SQL> create user xff identified by xifenfei;
create user xff identified by xifenfei
      *
ERROR at line 1:
ORA-65096: invalid common user or role name
 
 
SQL> !oerr ora 65096
65096, 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    103
C##XFF       3    104
 
SQL> alter session set container=pdb1;
 
Session altered.
 
SQL> show con_name
 
CON_NAME
------------------------------
PDB1
SQL> 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                 1
 
SQL> 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                 1
C##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 sysdba
Connected.
SQL> show parameter open_cursors;
 
NAME                 TYPE    VALUE
------------------------------------ ----------- ------------------------------
open_cursors             integer   500
SQL> 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 fixed
tables or views only
 
 
SQL> 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   100
SQL> conn / as sysdba
Connected.
SQL> show parameter open_cursors;
 
NAME                 TYPE    VALUE
------------------------------------ ----------- ------------------------------
open_cursors             integer   500

这里可以看到在cdb中修改,pdb会继承进去;如果在pdb中修改会覆盖pdb从cdb中继承的参数含义

    您感兴趣的教程

    在docker中安装mysql详解

    本篇文章主要介绍了在docker中安装mysql详解,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编...

    详解 安装 docker mysql

    win10中文输入法仅在桌面显示怎么办?

    win10中文输入法仅在桌面显示怎么办?

    win10系统使用搜狗,QQ输入法只有在显示桌面的时候才出来,在使用其他程序输入框里面却只能输入字母数字,win10中...

    win10 中文输入法

    一分钟掌握linux系统目录结构

    这篇文章主要介绍了linux系统目录结构,通过结构图和多张表格了解linux系统目录结构,感兴趣的小伙伴们可以参考一...

    结构 目录 系统 linux

    PHP程序员玩转Linux系列 Linux和Windows安装

    这篇文章主要为大家详细介绍了PHP程序员玩转Linux系列文章,Linux和Windows安装nginx教程,具有一定的参考价值,感兴趣...

    玩转 程序员 安装 系列 PHP

    win10怎么安装杜比音效Doby V4.1 win10安装杜

    第四代杜比®家庭影院®技术包含了一整套协同工作的技术,让PC 发出清晰的环绕声同时第四代杜比家庭影院技术...

    win10杜比音效

    纯CSS实现iOS风格打开关闭选择框功能

    这篇文章主要介绍了纯CSS实现iOS风格打开关闭选择框,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作...

    css ios c

    Win7如何给C盘扩容 Win7系统电脑C盘扩容的办法

    Win7如何给C盘扩容 Win7系统电脑C盘扩容的

    Win7给电脑C盘扩容的办法大家知道吗?当系统分区C盘空间不足时,就需要给它扩容了,如果不管,C盘没有足够的空间...

    Win7 C盘 扩容

    百度推广竞品词的投放策略

    SEM是基于关键词搜索的营销活动。作为推广人员,我们所做的工作,就是打理成千上万的关键词,关注它们的质量度...

    百度推广 竞品词

    Visual Studio Code(vscode) git的使用教程

    这篇文章主要介绍了详解Visual Studio Code(vscode) git的使用,小编觉得挺不错的,现在分享给大家,也给大家做个参考。...

    教程 Studio Visual Code git

    七牛云储存创始人分享七牛的创立故事与

    这篇文章主要介绍了七牛云储存创始人分享七牛的创立故事与对Go语言的应用,七牛选用Go语言这门新兴的编程语言进行...

    七牛 Go语言

    Win10预览版Mobile 10547即将发布 9月19日上午

    微软副总裁Gabriel Aul的Twitter透露了 Win10 Mobile预览版10536即将发布,他表示该版本已进入内部慢速版阶段,发布时间目...

    Win10 预览版

    HTML标签meta总结,HTML5 head meta 属性整理

    移动前端开发中添加一些webkit专属的HTML5头部标签,帮助浏览器更好解析HTML代码,更好地将移动web前端页面表现出来...

    移动端html5模拟长按事件的实现方法

    这篇文章主要介绍了移动端html5模拟长按事件的实现方法的相关资料,小编觉得挺不错的,现在分享给大家,也给大家...

    移动端 html5 长按

    HTML常用meta大全(推荐)

    这篇文章主要介绍了HTML常用meta大全(推荐),文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参...

    cdr怎么把图片转换成位图? cdr图片转换为位图的教程

    cdr怎么把图片转换成位图? cdr图片转换为

    cdr怎么把图片转换成位图?cdr中插入的图片想要转换成位图,该怎么转换呢?下面我们就来看看cdr图片转换为位图的...

    cdr 图片 位图

    win10系统怎么录屏?win10系统自带录屏详细教程

    win10系统怎么录屏?win10系统自带录屏详细

    当我们是使用win10系统的时候,想要录制电脑上的画面,这时候有人会想到下个第三方软件,其实可以用电脑上的自带...

    win10 系统自带录屏 详细教程

    + 更多教程 +
    MsSqlMysqloracleMariaDBSQLiteDB2