Common User vs. Local User – 12c Edition
Within Oracle Database 12c, there is new terminology being used for user accounts. Oracle has come up with a concept called COMMON USERS and LOCAL USERS. Ok, I know you are wondering what is the difference. A COMMON USER is a database user whose identity and password are known in the root (CDB) and in every (existing/future) pluggable database (PDB).
-
A COMMON USER can perform administrative tasks that are specific to the CDB or PDB, such as plugging and unplugging a PDB. COMMON USERs are the only ones that can navigate between containers that belong to a CDB.
-
When creating a COMMON USER account there are specific rules that must be followed:
-
Must be connected to the root and have the commonly granted CREATE USER system privilege
-
The session’s current container must be CDB$ROOT
-
The user name must start with C## or c##
-
Explicitly designate a user account as a common user, specify the CONTAINER=ALL as part of the CREATE USER statement
-
Do not create objects in the schemas of common users.
-
If specifying the DEFAULT TABLESPACE, TEMPORARY TABLESPACE, QUOTA… ON, and PROFILE clauses as part of CREATE USER; then you must ensure that those objects existing in all containers (PDB) below the CDB
-
User-created schema objects owned by COMMON USERS cannot be shared across PDB boundaries
Now that we have outlined what a COMMON USER is, lets take a look at creating one with the CREATE USER sql syntax. We need to create a COMMON USER for the CDB:
CREATE USER c##admin
IDENTIFIED BY welcome1
DEFAULT TABLESPACE USERS
QUOTA unlimited on USERS
TEMPORARY TABLESPACE temp
CONTAINER = ALL;Error starting at line 3 in command:
Error at Command Line:17 Column:1
Error report:
SQL Error: ORA-65048: error encountered when processing the current DDL statement in pluggable database BEERS
ORA-00959: tablespace 'USERS' does not exist
Oh, we got an error. What is it? The ORA-65048 error is thrown when the CREATE USER statement looks in the PDB (BEERS) for the USERS table. The next error ORA-00959, tells us that the USERS tablespace does not exist. These errors are thrown because the CREATE USER statement didn’t meet requirement 8 listed above. How do we correct this issue then? I can tell you, that MOS does not have any (at time of writing) support docs for ORA-65048/ORA-00959 yes, I looked. Keeping in mind, requirement 8 is being violated; when I look at the PDB (BEERS), I see that I don’t have a USERS tablespace. What would happen if I remove the tablespace and quota options? We end up with a very simple CREATE USER statement which creates successfully.
CREATE USER c##admin
IDENTIFIED BY welcome1
CONTAINER = ALL;user C##ADMIN created.
Now that we understand what a COMMON USER is, what about a LOCAL USER?
LOCAL USERS are a database user that exists only in a single PDB. LOCAL USERS can have administrative privileges, but these privileges are localized to the PDB what the account is created in. LOCAL USERS have the following characteristics:
-
LOCAL USER accounts cannot create user accounts or commonly grant them privileges.
-
Can grant local user accounts common roles. However, the privileges associated with the common role only apply to the local user’s PDB
-
LOCAL USER account must be unique only within its PDB
-
With the appropriate privileges, a local user can access object in a common user’s schema
-
Can be editions-enable a local user account but not a common user account
Now that the LOCAL USER has been outlined, lets look at creating a LOCAL USER in the PDB (BEERs) with the CREATE USER syntax. We need to create a LOCAL USER for a PDB. Below is the SQL I used to create user BARMAID.
ALTER SESSION SET CONTAINER = BEERS;CREATE USER barmaid
IDENTIFIED BY beers
DEFAULT TABLESPACE beers
QUOTA unlimited on beers_part1
QUOTA unlimited on beers_part2
QUOTA unlimited on beers_part3
TEMPORARY TABLESPACE temp
CONTAINER = BEERS;Error at Command Line:8 Column:13
Error report:
SQL Error: ORA-65013: invalid CONTAINER clause
You will notice that we first have to alter our session and move from the CDB into the PDB (BEERS) container. This is actually placing us into the PDB. Next we try to create the user BARMAID. Everything is set correctly, tablespaces are there, quotas are assigned, what caused the error? Error was caused from the ORA-65013. The ORA-65013 is complaining about the value of the CONTAINER class. Remember, we are already in the PDB and we need to create the user. This means we need to set CONTAINER equal to CURRENT. Lets see what happens:
CREATE USER barmaid
IDENTIFIED BY beers
DEFAULT TABLESPACE beers
QUOTA unlimited on beers_part1
QUOTA unlimited on beers_part2
QUOTA unlimited on beers_part3
TEMPORARY TABLESPACE temp
CONTAINER = CURRENT;user BARMAID created.
Wala, the user is created.
In the end, when creating users we have to understand that there are some new rules for creating a use in multi-tenet databases. The basic rules that should be taken away are:
-
COMMON USERS must always be created at the CDB level and start with a C## or c## prefixes.
-
LOCAL USERS can only be created at the PDB layer; also must use the CONTAINER clause set to CURRENT for the user to be created.
Well I hope everyone got something out of this post.
Enjoy!
twitter: @curtisbl294
blog: http://dbasolved.com
Current Oracle Certs
Bobby Curtis
I’m Bobby Curtis and I’m just your normal average guy who has been working in the technology field for awhile (started when I was 18 with the US Army). The goal of this blog has changed a bit over the years. Initially, it was a general blog where I wrote thoughts down. Then it changed to focus on the Oracle Database, Oracle Enterprise Manager, and eventually Oracle GoldenGate.
If you want to follow me on a more timely manner, I can be followed on twitter at @dbasolved or on LinkedIn under “Bobby Curtis MBA”.
best site to buy priligy canada and Hallfrisch, J
I Left pAKT, AKT, PI3K, pRSK, RSK pERK and ERK levels in HeLa cells overexpressing siHO, Antisense, HOTAIR, or HOTAIRm as determined by Western blotting priligy in usa