oracle12c 之 oerr ora 65096引出的CDB/PDB

时间:2021-04-26 16:50:03

SQL> create user crm identified by crm;
create user crm identified by crm
            *
第 1 行出现错误:
ORA-65096: 公用用户名或角色名无效

 

这个错误在之前一直没有遇到过,查询metalink(id 文档 ID 1572404.1)等,发现这个是oracle12c的新特性决定的

一、CDB/PDB

 

 

SQL> conn /as sysdba

SQL> show con_name;

CON_NAME
------------------------------
CDB$ROOT

SQL> select PDB from v$services;

PDB
------------------------------
PDBORCL
CDB$ROOT
CDB$ROOT
CDB$ROOT
CDB$ROOT

 

SQL> alter session set container=PDBORCL;

会话已更改。

SQL> show con_name

CON_NAME
------------------------------
PDBORCL

 

SQL> create user crmm identified by crmm;
create user crmm identified by crmm
                               *
第 1 行出现错误:
ORA-01109: 数据库未打开

 

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         3 PDBORCL                        MOUNTED

 

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         3 PDBORCL                        MOUNTED

 

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         3 PDBORCL                        MOUNTED

SQL> alter database open;

数据库已更改。

 

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         3 PDBORCL                        READ WRITE NO

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         3 PDBORCL                        READ WRITE NO