Oracle12c creates a new user prompting that the public username or role is invalid

 To restore the backed up database to a new computer today, first create a user and execute the following statement:
create user fxhy
identified by "123456"
default tablespace USERS
temporary tablespace TEMP;

  The result is an error:

  

  We can see that the prompt is: the public username or role is invalid. At this time, I was depressed. Uh, I checked the information and found that when creating a user, it should start with c##, that is, the creation statement just now should be written like this:

create user c##fxhy
identified by "123456"
default tablespace USERS
temporary tablespace TEMP;

  I tried it like this, and the creation was successful, but why I did this, I didn't understand, and then I continued to check the information. The reason is as follows:

  Oracle 12C introduces new features of CDB and PDB. In the Multitenant Environment (Multitenant Environment) introduced by the ORACLE 12C database, one database container (CDB) is allowed to host multiple pluggable databases (PDB). The full name of CDB is Container Database, which is translated into database container in Chinese, and the full name of PDB is Pluggable Database, which is a pluggable database. Prior to ORACLE 12C, instances and databases had a one-to-one or many-to-one relationship (RAC): that is, an instance could only be associated with one database, and the database could be loaded by multiple instances. An instance and a database cannot have a one-to-many relationship. When entering ORACLE 12C, the instance and the database can have a one-to-many relationship. The following is the official document on the relationship between CDB and PDB.

  

  

  Components of a CDB

     A CDB database container contains the following components:

    ROOT component

       ROOT is also called CDB$ROOT, which stores the metadata and Common User provided by ORACLE. An example of the metadata is the source code of the PL/SQL package provided by ORACLE. Common User refers to the user that exists in each container.

    SEED components

        Seed is also called PDB$SEED. This is a template for you to create a PDBS database. You cannot add or modify an object in Seed. There can only be one Seed in a CDB. Personally, this feeling is very similar to the model database in SQL SERVER.

    PDBS

         There can be one or more PDBS in the CDB, PDBS is backward compatible, PDBS can be operated as before in the database, here refers to most normal operations.

  Each of these components can be called a container. So ROOT (root) is a container, Seed (seed) is a container, and each PDB is a container. Each container has a unique ID and name in the CDB.

  How to check whether the database is a CDB?

    Execute the following statement:    

select CDB from v$database;

    If the result is YES, then it is the CDB database, otherwise, it is not.

  How can I view the current container?

    Execute the following statement:

show con_name;

    The execution result is as follows:

     

  How to check PDB information in CDB?

    Execute the following statement:      

select con_id, dbid, guid, name , open_mode from v$pdbs;
   The execution result is as follows:

   

 The way to start the PDB database:
  
   Execute the following statement:
 
     
alter pluggable database PDBORCL open;
   The execution result is as follows:

  

The way to close the PDB database:
  
   Execute the following statement:
 
alter pluggable database PDBORCL close;
   The execution result is as follows:

  Switch between containers:   

alter session set container=PDBORCL;
alter session set container=CDB$ROOT;

-------------------------------------------------- ------------Dividing line------------------------------------ ------------------------------------

So having said so much, how can you create a user without adding c##? I will create a new database here. The steps are as follows:

  Open the Database Configuration Assistant

  

  The following interface appears:

  Click "Next" and the following interface will appear. When creating a database, uncheck the "Create as a container database" item.

  The newly created database is then ready to use.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325895599&siteId=291194637