This entry is part 6 of 6 in the series Setting up an Oracle 12c R2 Lab

During Part 4 of this series when we created our first Oracle database we opted to load the example HR schema into the database. The HR schema can be compared to that of Microsoft’s AdventureWorks – sort of an example database in which we can play with in order to learn SQL and perform different queries. AdventureWorks is loaded into MSSQL as a backup of a database, restored into our instance – the HR schema though is a little different.  In older versions of Oracle it apparently was much easier to load the HR schema however due to the multitenancy and container database features in Oracle 12C it’s a little bit different.  That said, let’s look at how to unlock the HR account and load the schema.

The first step would be to set up our PDB as a service, however, we already did this in Part 5 so yay for us!  We can simply jump into sqlplus and get the job done!

The first thing we need to do is log into sqlplus and connect to the default container database.

SQL> sqlplus / as sysdba

From there, let’s navigate to our actual PDB, the database we would like the HR schema loaded in

SQL> ALTER SESSION SET CONTAINER = cbd1pdb;

In order to unlock the schema for HR we simply need to unlock the HR user account and give it a password

SQL> ALTER USER hr IDENTIFIED BY NewPassword ACCOUNT unlock;

Finally, let’s connect to our PDB as the hr user.

SQL> CONNECT hr/NewPassword @cdb1pdb;

And just for fun, let’s list out our tables…

SQL> SELECT table_name FROM user_tables;

You can see below the results from all of the commands in my environment

There we have it – the user account hr is unlocked and we can see a bunch of example tables created for us already – Heading over to SQL Developer and connecting with the HR users shows us that there is indeed a bunch of data there for us to learn and play with. For example, let’s see if we can’t figure out how many countries are located in each region 🙂

So with that let’s end this series on getting an Oracle Lab setup and configured. Now it’s on to hopefully developing some sort of study guide for the Oracle SQL Database Certification. This lab will serve as a pretty good base for learning the differences between Oracle and MS SQL languages as well as getting a handle on sqlplus.  As I move more into the administration exam I may need to expand to learn RAC – but for now, this will do!  Thanks for reading!

Series Navigation<< Setting up an Oracle 12c R2 Lab for the Administration Certified Associate Certification – Part 5 – Connecting to Oracle Databases with SQL Developer