First of all, basic usage:
First press 11G before
Conn/as Sysdba;
Create user test identifed by test;
ORA-65096: The public user name or role name is invalid.
Check the official document that "trying to create a generic user, you will need to use C # #或者c # #开头", this time there will be doubt, what is common user? No matter how successful the first build.
Create C # #user test identifed by test;
Create success
Sql>show Con_name;
Con_name
------------------------------
Cdb$root
Selectcon_id,dbid,name,open_modefromv$pdbs;
con_id DBID NAME Open_mode
---------- ---------- ------------------------------ ----------
2 4066409480 pdb$seed READ only
3 2270995695 PDBORCL Mounted
Sql>alter session Set CONTAINER=PDBORCL;
You can then use the Create user test identifed by test;
CDB and PDB are a bright new feature of Oracle 12C, as their introduction has led to a number of changes in traditional Oracle database management concepts, listing some of the most basic CDB and PDB management methods
CDB and PDB diagrams
ORACLE 12C Version
Sql> select * from V$version;
BANNER con_id
---------------------------------------------------------------------------------------- --
Oracle Database 12c Enterprise Edition release 12.1.0.1.0-64bit Production 0 pl/sql release
12.1.0.1.0- Production 0
CORE 12.1.0.1.0 Production 0
TNS for linux:version 12.1.0.1.0-production 0
Nlsrtl Version 12.1.0.1.0-production 0
Start shutdown PDB
Sql> Startup ORACLE instance started. Total System Global area 597098496 bytes Fixed Size 2291072 bytes Variable Size 272632448 bytes Database Buf
Fers 314572800 bytes Redo buffers 7602176 Database bytes.
Database opened.
Sql> select Con_id,dbid,name,open_mode from V$pdbs; con_id DBID NAME open_mode------------------------------------------------------------2 40488216
3313918585 pdb$seed READ only 3 PDB1 mounted 4 3872456618 PDB2 mounted
sql> Alter pluggable database PDB1 open;
Pluggable database altered.
Sql> select Con_id,dbid,name,open_mode from V$pdbs; con_id DBID NAME open_mode------------------------------------------------------------2 40488216 3313918585 Pdb$seed Read Only 3 PDB1 read WRITE 4 3872456618 PDB2 Mounte
D sql> Alter pluggable database PDB1 close; PluggaBLE database altered.
Sql> select Con_id,dbid,name,open_mode from V$pdbs; con_id DBID NAME open_mode------------------------------------------------------------2 40488216
3313918585 pdb$seed READ only 3 PDB1 mounted 4 3872456618 PDB2 mounted
Sql> Alter pluggable database all open;
Pluggable database altered.
Sql> select Con_id,dbid,name,open_mode from V$pdbs; con_id DBID NAME open_mode------------------------------------------------------------2 40488216 Pdb$seed Read Only 3 3313918585 PDB1 read WRITE 4 3872456618 PDB2 Read W
RITE sql> Alter pluggable database all close;
Pluggable database altered.
Sql> select Con_id,dbid,name,open_mode from V$pdbs; con_id DBID NAME open_mode------------------------------------------------------------2 40488216 Pdb$seed READ onLY 3 3313918585 PDB1 mounted 4 3872456618 PDB2 mounted sql> alter session set con
TAINER=PDB1;
Session altered.
Sql> Startup pluggable Database opened.
Sql> select Con_id,dbid,name,open_mode from V$pdbs; con_id DBID NAME open_mode------------------------------------------------------------3 33139185 PDB1 READ WRITE
The management of the PDB can be done in CDB or in the PDB, and if it is done in CDB, the pluggable keyword is required, if it is directly in the PDB as the normal database
Log on to the PDB
[Oracle@xifenfei ~]$ lsnrctl status lsnrctl for Linux:version 12.1.0.1.0-production on 12-may-2013 08:07:02 Copyri Ght (c) 1991, 2013, Oracle.
All rights reserved. Connecting to (description= address= (protocol=tcp) (Host=xifenfei) (port=1521)) STATUS of the LISTENER--------------- ---------Alias LISTENER Version Tnslsnr for linux:version 12.1.0.1.0-production Start Date 1 1-may-2013 18:30:54 Uptime 0 hr. 8 sec Trace level off security on:local OS authe Ntication SNMP off Listener Parameter file/u01/app/grid/product/12.1/network/admin/listener.ora Listener Log F
Ile/u01/app/grid/diag/tnslsnr/xifenfei/listener/alert/log.xml Listening Endpoints Summary ...
(Description= (address= (PROTOCOL=IPC) (key=extproc1521))
(Description= (address= (protocol=tcp) (Host=xifenfei) (port=1521)) (Description= (address= (PROTOCOL=TCPS) (Host=xifenfei) (port=5500)) (Security= (my_wallet_directory=/u01/oracle/ 12.1/db_1/admiN/cdb/xdb_wallet)) (presentation=http) (Session=raw)) Services Summary ...
Service "+asm" has 1 instance (s).
Instance "+asm", Status READY, has 1 handler (s) for the This service ...
Service "CDB" has 1 instance (s).
Instance "CDB", Status READY, has 1 handler (s) for the This service ...
Service "Cdbxdb" has 1 instance (s).
Instance "CDB", Status READY, has 1 handler (s) for the This service ...
Service "PDB1" has 1 instance (s).
Instance "CDB", Status READY, has 1 handler (s) for the This service ...
Service "PDB2" has 1 instance (s).
Instance "CDB", Status READY, has 1 handler (s) for the This service ... The command completed successfully [Oracle@xifenfei ~]$ tnsping pdb1 TNS Ping Utility for Linux:version 12.1.0.1.0-PR Oduction on 12-may-2013 08:07:09 Copyright (c) 1997, 2013, Oracle.
All rights reserved. Used parameter files:used TNSNAMES adapter to resolve the alias attempting to contacts (DESCRIPTION = (address = (prot Ocol = TCP) (HOST = Xifenfei) (PORT = 1521)) (Connect_data = (SERVER = dedicated) (service_name = pdb1)) OK (msec) [Oracle@xifenfei ~]$ sqlplus sys/xifenfei@pdb1 as Sysdba sql*plus:release 12.1.0.1.0 Production on Sun May 08:08:02 2013 Copyright (c) 1982, 2013, Oracle.
All rights reserved. Connected to:oracle Database 12c Enterprise Edition release 12.1.0.1.0-64bit Production with the partitioning, Automati
C Storage Management, OLAP, Advanced Analytics and real application testing the options sql> show Con_name; Con_name------------------------------PDB1 [Oracle@xifenfei ~]$ sqlplus/as sysdba sql*plus:release 12.1.0.1.0 P Roduction on Sun May 08:09:14 2013 Copyright (c) 1982, 2013, Oracle.
All rights reserved. Connected to:oracle Database 12c Enterprise Edition release 12.1.0.1.0-64bit Production with the partitioning, Automati C Storage Management, OLAP, Advanced Analytics and real application testing options sql> alter session set container=
PDB1;
Session altered.
Sql> show Con_name; Con_name------------------------------PDB1
The PDB can be entered via alter session container and can be logged in directly through TNS
Create a user
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 40488216 3313918585 Pdb$seed Read Only 3 PDB1 read WRITE 4 3872456618 PDB2 Mounte
D sql> Create user xff identified by Xifenfei; Create user Xff identified by Xifenfei * ERROR on line 1:ora-65096:invalid Common user or role name sql>!o Err ora 65096 65096, 00000, "Invalid common user or role name"//*cause:an attempt is made to create a common user or R OLE with a name//is wass 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 ASCII//characters.
*action:specify a valid common user or role name. sql> Create User C # #xFF identified by Xifenfei;
User created.
Sql> SELECT username,con_id,user_id from cdb_users WHERE username= ' C # #XFF '; USERNAME con_id user_id------------------------------C # #XFF 1 $ C # #XFF 3 sql> alter S
Ession set CONTAINER=PDB1;
Session altered.
Sql> show Con_name con_name------------------------------PDB1 sql> Create user xff by identified;
User created.
sql> Create User C # #abc identified by Xifenfei; Create User C # #abc identified by Xifenfei * ERROR on line 1:ora-65094:invalid The local user or role name
Creating a user By default is Container=all, only global users (C # #开头) can be created in CDB, and the user is created in CDB and all PDB (but global users in the PDB need additional authorization to access in the PDB). Only users created in the PDB are local users
User authorization
Sql> Grant Connect to C # #xff;
Grant succeeded.
Sql> Select grantee,con_id from Cdb_role_privs where granted_role= ' CONNECT ' and grantee= ' C # #XFF ';
Grantee con_id
----------------------------------------
C # #XFF 1
sql> Grant resource to c## Xff Container=all;
Grant succeeded.
Sql> Select grantee,con_id from Cdb_role_privs where granted_role= ' RESOURCE ' and grantee= ' C # #XFF ';
Grantee con_id
----------------------------------------
C # #XFF 1
C # #XFF 3
User authorization is only given to the current container by default, and Container=all can also be specified in CDB, which is authorized for all the PDB of the open and for the existence of that user
modifying parameters
Sql> alter system set OPEN_CURSORS=500 Container=all;
System altered.
Sql> Conn SYS/XIFENFEI@PDB1 as Sysdba Connected.
Sql> Show parameter open_cursors; NAME TYPE VALUE-----------------------------------------------------------------------------OPEN_CU
Rsors integer sql> alter system set OPEN_CURSORS=100; Alter system set OPEN_CURSORS=100 * ERROR at line 1:ora-01219:database or pluggable database not open:queries allowed O
n Fixed tables or views only sql> ALTER DATABASE open;
Database altered.
Sql> alter system set OPEN_CURSORS=100;
System altered.
Sql> Show parameter open_cursors; NAME TYPE VALUE-----------------------------------------------------------------------------OPEN_CU
Rsors integer sql> conn/as sysdba Connected.
Sql> Show parameter open_cursors; NAME TYPE VALUE-----------------------------------------------------------------------------open_cursors Integer 500
You can see here that the PDB will inherit in CDB, and if the modification in the PDB overwrites the parameter meaning that the PDB inherits from CDB