SQL 错误: 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
在Oracle SQL Developer中,试图创建RD用户时,出现了如下的错误:
在行: 6 上开始执行命令时出错 - create user RD identified by 508 错误报告 - SQL 错误: 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 was 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>show con_name;
SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs;
SQL> alter session set container=ORCLE;
SQL> startup
Microsoft Windows [版本 10.0.17763.864] (c) 2018 Microsoft Corporation。保留所有权利。 C:\Users\Raodi>sqlplus sys as sysdba SQL*Plus: Release 12.2.0.1.0 Production on 星期一 11月 18 09:25:49 2019 Copyright (c) 1982, 2016, Oracle. All rights reserved. 输入口令: 连接到: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production 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 1662417127 PDB$SEED READ ONLY 3 1853089480 ORCLE MOUNTED CON_ID DBID ---------- ---------- NAME -------------------------------------------------------------------------------- OPEN_MODE -------------------- SQL> alter session set container=ORCLE; 会话已更改。 SQL> create user RD identifed by 123456; create user RD identifed by 123456 * 第 1 行出现错误: ORA-00922: 选项缺失或无效 SQL> create user RD identified by 508; create user RD identified by 508 * 第 1 行出现错误: ORA-01109: 数据库未打开 SQL> startup 插接式数据库已打开。 SQL> create user RD identified by 508; 用户已创建。 SQL> grant create session ,dba,resource to RD; 授权成功。 SQL> Grant UNDER ANY TYPE to RD; 授权成功。 SQL>
其中container的内容,建议不要使用OPEN_MODE是READ ONLY的,不然相当于只进行了默认的操作。同时,alter session set container的方式只是局部范围中能用,比如此次cmd的界面中,如果切换回Oracle SQL Developer中,是不起效果的,如下举一个例子:创建一个不带C##开头的用户stest,效果是这样的,说明刚才在cmd中的操作暂时没有在
Oracle SQL Developer中起效。