Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Database 12c
I have been asked several times about how one can unlock HR schema or user in oracle database
12c? In this blog I will try to answer your question along with some common errors which you may
face during or after unlocking the HR schema in Oracle Database 12c.
So lets go ahead and see how we can unlock HR user in Oracle Database 12c.
Because of the new and updated architecture of Oracle 12c a.k.a Multitenant Architecture, the
process of unlocking the HR schema is not as simple as it was with the earlier versions of oracle
database. We have to do some settings before unlocking the HR schema in oracle 12c.
In oracle database 12c multitenant architecture we have a container database (CBD) which has at
least one Seed pluggable database (PDB) and can have up to 252 user created pluggable
databases. Furthermore in oracle database 12c the HR sample schema is placed inside the
pluggable database which is created either during the installation of the Oracle Database 12c or
during the creation of a new container database.
So lets see the steps for unlocking the HR schema in oracle Database 12c.
1. PDB$SEED: First is PDB$SEED which has container id 2. This is our seed PDB which is
a default pluggable database (PDB) used as a template for user-created PDBs by the
system. The seed is always named PDB$SEED.
2. Second is PDBORCL which has container id 3. This pluggable database is the one that
was created by me during the installation of oracle database 12c which has our sample
HR schema.
To find the name of the service we will use v$active_services view. In most of the cases oracle
software creates database and its service with the same name.
The result returned from this query in my case is pdborcl which is the name of the service for
my pluggable database PDBORCL. Dont get confused here as I have already mentioned that
in most cases the oracle software creates database and its service with same name.
This pluggable database name and service name will be used for updating tnsname.ora file and
configuring some network settings in it by making service entry for the pluggable database.
Question: How do we get to know which pluggable database from the list has the HR sample
schema?
Answer: Generally the first pluggable database which is created during the creation of the
container database (either at the time of Oracle Software installation or database creation using
DBCA) consists the HR sample schema.
First open up your TNS file. This file normally resides in the ORACLE HOME\NETWORK\ADMIN
directory.
Remember in my case the name of the pluggable database is PDBORCL and the service name
is also pdborcl. I will use this information to add an entry in my tnsname.ora file.
Before making any changes in the tnsname.ora file I would suggest you to make its duplicate
copy as a backup.
PDBORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdborcl)
)
)
A sample entry will look like this. You can change the value for hostname and port number
accordingly.
Step3: Switch the container from CBD$ROOT to
PDBORCL
As I mentioned at the starting of this blog that in oracle database 12c the HR sample schema is
the part of the pluggable database thus in order to unlock it we need to switch the container from
Root CBD to Pluggable PDB (pdborcl).
To switch the container first you need to log on to your database using sys user again
You can check the present open mode of pluggable database using v$pdbs view.
1. ORA- 12154: TNS: could not resolve the connect identifier specified.
Cause: Either you forgot to add a service entry in your tnsname.ora file as mentioned in Step 2
or you have supplied the wrong value of the service parameters such as SERVICE_NAME,
LOCALHOST etc.
Solution: Add a service entry for your pluggable database in your tnsname.ora file as shown in
step 2 or check whether the value that you have specified for parameters are correct or not.
Solution:First check the open mode for your pluggable database using v$pdbs view