错误:ORA-65096:oracle 中的通用用户名或角色名无效

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33330968/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 00:57:43  来源:igfitidea点击:

error: ORA-65096: invalid common user or role name in oracle

oracleoracle12c

提问by enu

I just installed oracle11g, and it was missing the Scott schema. So i am trying to generate it myself. I got the sql script of "Scott" schema, but when i try to run the query "create user Scott identified by tiger;" it displays the following error:

我刚刚安装了 oracle11g,它缺少 Scott 模式。所以我想自己生成它。我得到了“斯科特”模式的 sql 脚本,但是当我尝试运行查询“创建由老虎识别的用户斯科特”时;它显示以下错误:

ORA-65096: invalid common user or role name in oracle.

ORA-65096: oracle 中的通用用户名或角色名无效。

Basically it is not allowing me to create a user "Scott". Why is that, and how can I fix my problem?

基本上它不允许我创建用户“Scott”。为什么会这样,我该如何解决我的问题?

回答by Dr Alchemy

Before creating the user run:

在创建用户之前运行:

alter session set "_ORACLE_SCRIPT"=true;  

I found the answer here

我在这里找到了答案



Please be aware that setting undocumented parameters like this (as indicated by the leading underscore) should only be done under the direction of Oracle Support. Changing such parameters without such guidance may invalidate your support contract. So do this at your own risk.

请注意,像这样设置未记录的参数(如前导下划线所示)只能在 Oracle Support 的指导下完成。在没有此类指导的情况下更改此类参数可能会使您的支持合同无效。因此,请自行承担风险。

回答by Lalit Kumar B

I just installed oracle11g

ORA-65096: invalid common user or role name in oracle

我刚刚安装了 oracle11g

ORA-65096: oracle 中的通用用户名或角色名无效

No, you have installed Oracle 12c. That error could only be on 12c, and cannot be on 11g.

不,您已经安装了Oracle 12c。该错误只能在 上12c,不能在 上11g

Always check your database versionup to 4 decimal places:

始终检查您的数据库版本,最多保留 4 位小数:

SELECT banner FROM v$version WHERE ROWNUM = 1;

Oracle 12c multitenant container databasehas:

Oracle 12c 多租户容器数据库具有:

  • a root container(CDB)
  • and/or zero, one or many pluggable databases(PDB).
  • 一个根容器(CDB
  • 和/或零个、一个或多个可插拔数据库 ( PDB)。

You must have created the database as a container database. While, you are trying to create user in the container, i.e. CDB$ROOT, however, you should create the user in the PLUGGABLE database.

您必须已将数据库创建为容器数据库。虽然您尝试在容器中创建用户,即CDB$ROOT,但是,您应该在PLUGGABLE 数据库中创建用户。

You are not supposed to create application-related objects in the container, the container holds the metadata for the pluggable databases. You should use the pluggable database for you general database operations. Else, do not create it as container, and not use multi-tenancy. However, 12cR2 onward you cannot create a non-container database anyway.

您不应该在容器中创建与应用程序相关的对象,容器保存可插入数据库的元数据。您应该将可插拔数据库用于常规数据库操作。否则,不要将其创建为容器,也不要使用multi-tenancy。但是,从 12cR2 开始,您无论如何都无法创建非容器数据库。

And most probably, the sample schemasmight have been already installed, you just need to unlockthem in the pluggable database.

最有可能的是,示例模式可能已经安装,您只需要在可插入数据库中解锁它们。

For example, if you created pluggable database as pdborcl:

例如,如果您将可插入数据库创建为pdborcl

sqlplus SYS/password@PDBORCL AS SYSDBA

SQL> ALTER USER scott ACCOUNT UNLOCK IDENTIFIED BY tiger;

sqlplus scott/tiger@pdborcl

SQL> show user;
USER is "SCOTT"

To show the PDBs and connect to a pluggable database from root container:

要显示 PDB 并从根容器连接到可插拔数据库:

SQL> show con_name

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

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 ORCLPDB                        READ WRITE NO

SQL> alter session set container = ORCLPDB;

Session altered.

SQL> show con_name;

CON_NAME
------------------------------
ORCLPDB

I suggest read, Oracle 12c Post Installation Mandatory Steps

我建议阅读Oracle 12c Post Installation Mandatory Steps



Note: Answers suggesting to use the _ORACLE_SCRIPThidden parameter to set to true is dangerous in a production system and might also invalidate your support contract. Beware, without consulting Oracle support DO NOT use hidden parameters.

注意:建议使用_ORACLE_SCRIPT隐藏参数设置为 true 的答案在生产系统中是危险的,并且还可能使您的支持合同无效。请注意,在未咨询 Oracle 支持的情况下,请勿使用隐藏参数

回答by Steve Ruben

In Oracle 12c and above, we have two types of databases:

在 Oracle 12c 及更高版本中,我们有两种类型的数据库:

  1. Container DataBase (CDB), and
  2. Pluggable DataBase (PDB).
  1. 容器数据库 (CDB),以及
  2. 可插拔数据库 (PDB)。

If you want to create an user, you have two possibilities:

如果要创建用户,有两种可能:

  1. You can create a "container user" aka "common user".
    Common users belong to CBDs as well as to current and future PDBs. It means they can perform?operations in Container DBs or Pluggable DBs according to assigned privileges.

    create user c##username identified by password;

  2. You can create a "pluggable user" aka "local user".
    Local users?belong only to a single PDB. These users may be given administrative privileges, but only for that PDB inside which they exist. For that, you should connect to pluggable datable like that:

    alter session set container = nameofyourpluggabledatabase;

    and there, you can create user like usually:

    create user username identified by password;

  1. 您可以创建一个“容器用户”又名“普通用户”。
    普通用户属于 CBD 以及当前和未来的 PDB。这意味着他们可以根据分配的权限在容器数据库或可插拔数据库中执行操作。

    create user c##username identified by password;

  2. 您可以创建一个“可插入用户”又名“本地用户”。
    本地用户?只属于一个 PDB。这些用户可能被授予管理权限,但仅限于他们所在的 PDB。为此,您应该像这样连接到可插拔数据:

    alter session set container = nameofyourpluggabledatabase;

    在那里,您可以像往常一样创建用户:

    create user username identified by password;

Don't forget to specify the tablespace(s) to use, it can be useful during import/export of your DBs. See this for more information about it https://docs.oracle.com/database/121/SQLRF/statements_8003.htm#SQLRF01503

不要忘记指定要使用的表空间,它在数据库的导入/导出过程中很有用。有关它的更多信息,请参阅https://docs.oracle.com/database/121/SQLRF/statements_8003.htm#SQLRF01503

回答by Steve Ruben

If you face exact same error do below things:

如果您遇到完全相同的错误,请执行以下操作:

1) Open CMD type sqlplusand hit enter

1) 打开 CMD 类型sqlplus并回车

2) Connect from systemlogin

2)从系统登录连接

3) Run command : alter session set "_ORACLE_SCRIPT"=true;

3) 运行命令: alter session set "_ORACLE_SCRIPT"=true;

4) For creating another user run command: CREATE USER username IDENTIFIED BY password;

4)创建另一个用户运行命令: CREATE USER username IDENTIFIED BY password;

Then you can add user and roles.

然后您可以添加用户和角色。

回答by Balavenkareddy

Create user dependency upon the database connect tools

创建用户对数据库连接工具的依赖

sql plus
SQL> connect as sysdba;
Enter user-name: sysdba
Enter password:
Connected.
SQL> ALTER USER hr account unlock identified by hr;
User altered
 then create user on sql plus and sql developer