ORA-65096: invalid common user or role 解决方法
阿里云国内75折 回扣 微信号:monov8 |
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6 |
问题描述
oracle 12C 创建数据库时报错
ORA-65096: invalid common user or role name
例如
SQL> create user rui identified by oracle;
create user rui identified by oracle
*
ERROR at line 1:
ORA-65096: invalid common user or role name
原因
用户想在PDBORCL中创建新用户却未设置会话container到PDB而在CDB中创建公有用户因无法通过名称或角色验证出错。
解决方法
创建用户的时候用户名以c##或者C##开头。
如下
SQL> create user c##rui identified by oracle;
User created.
相应的对用户名进行其它操作也需要在用户名前加c##或者C##
例如
SQL> grant dba to c##rui;
Grant succeeded.
补充参考
https://www.cnblogs.com/siyunianhua/p/4004361.html
这篇文章主要介绍CDB和PDB的基本管理资料来源oracle官方。
基本概念
Multitenant Environment多租户环境
CDBContainer Database数据库容器
PDPluggable Database可插拔数据库
CDB与PDB关系图
COMMON USERS(普通用户)经常建立在CDB层用户名以C##或c##开头
LOCAL USERS(本地用户)仅建立在PDB层建立的时候得指定CONTAINER。
在oracle 12c中使用了一个container(容器)的概念让我们先看看官方的对它的介绍为了保留最原始的意思这里引用英文而不翻译了。
The data dictionary in each container in a CDB is separate, and the current container is the container whose data dictionary is used for name resolution and for privilege authorization. The current container can be the root or a PDB. Each session has exactly one current container at any point in time, but it is possible for a session to switch from one container to another.
Each container has a unique ID and name in a CDB. You can use the CON_ID and CON_NAME parameters in the USERENV namespace to determine the current container ID and name with the SYS_CONTEXT function.
1、查看Oracle 12c的版本
SQL> select * from v$version;
SQL>select sys_context ('USERENV', 'CON_NAME') from dual;
SYS_CONTEXT('USERENV','CON_NAME')
----------------------------------------------------------------------------------------------------
CDB$ROOT
2、我们可以通过ALTER SESSION SET CONTAINER 指定其他容器
SQL>select con_id,dbid,NAME,OPEN_MODE from v$pdbs;
3、将Pdb open
SQL> alter pluggable database pdborcl open;
4、查看容器
SQL>select con_id,dbid,NAME,OPEN_MODE from v$pdbs;
5、切换容器到pdb
SQL> alter session set container=PDBORCL;
6、查看当前使用容器
SQL>select sys_context (‘USERENV’, ‘CON_NAME’) from dual;
7、创建用户
SQL>create user informix identified by gmgl;
SQL>grant dba to informix;