问题
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:
ORA-65096: invalid common user or role name in oracle.
Basically it is not allowing me to create a user "Scott". Why is that, and how can I fix my problem?
回答1:
Before creating the user run:
alter session set "_ORACLE_SCRIPT"=true;
I found the answer here
回答2:
I just installed oracle11g
ORA-65096: invalid common user or role name in oracle
No, you have installed Oracle 12c. That error could only be on 12c
, and cannot be on 11g
.
Always check your database version up to 4 decimal places:
SELECT banner FROM v$version WHERE ROWNUM = 1;
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.
You are not supposed to create 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.
And most probably, the sample schemas might have been already installed, you just need to unlock them in the pluggable database.
For example, if you created pluggable database as 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"
I suggest read, Oracle 12c Post Installation Mandatory Steps
回答3:
In Oracle 12c and above, we have two types of databases:
- Container DataBase (CDB), and
- Pluggable DataBase (PDB).
If you want to create an user, you have two possibilities:
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;
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;
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
回答4:
If you face exact same error do below things:
1) Open CMD type sqlplus and hit enter
2) Connect from system login
3) Run command : alter session set "_ORACLE_SCRIPT"=true;
4) For creating another user run command: CREATE USER username IDENTIFIED BY password;
Then you can add user and roles.
回答5:
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
来源:https://stackoverflow.com/questions/33330968/error-ora-65096-invalid-common-user-or-role-name-in-oracle