No usename HR in Oracle 12c

pranphy picture pranphy · Nov 16, 2015 · Viewed 19k times · Source

I have installed oracle 12c in my ubuntu. I use oracle through sqldeveloper and I can successfully connect to user sys with my password. I want to be able to use all databases provided by oracle by default. When I try to connect with username hr with the same password as in sys I get error username not found.

select * from all_users doesn't list user hr. So I assume the user is not created at all.

  • Should it not have been available by default, hr user?
  • How can I configure such that I get the access to all `hr` databases?

Answer

Lalit Kumar B picture Lalit Kumar B · Nov 16, 2015

I have installed oracle 12c in my ubuntu. I assume the user is not created at all.

You have created the 12c database as a container. Now you might be connecting to the container database while the sample schemas reside in the pluggable database.

Oracle 12c has introduced multi-tenant architecture. There are some mandatory post-installation steps. Please read Oracle 12c Post Installation Mandatory Steps.

The most common misunderstanding is about “SQLPLUS / AS SYSDBA” usage.

Since we have checked the option to create a single CDB, the “SQLPLUS / AS SYSDBA” command will always log into CDB. Usually developers used to unlock the “SCOTT/HR” account directly after logging as SYSDBA. But here is the trick :

“SCOTT,HR” and other sample schemas are in the PDB and not in the CDB. So, you need to login as sysdba into PDB.

For example,

sqlplus SYS/password@PDBORCL AS SYSDBA

SQL> ALTER USER scott ACCOUNT UNLOCK IDENTIFIED BY tiger;

sqlplus scott/tiger@pdborcl

SQL> show user;
USER is "SCOTT"

UDPATE Seems OP has not installed the sample schemas. It could be done manually or via DBCA.

You need to run the hr_main.sql script. All scripts necessary to create the Human Resource (HR) schema reside in $ORACLE_HOME/demo/schema/human_resources.

From documentation,

Installing the HR Schema

All scripts necessary to create the Human Resource (HR) schema reside in $ORACLE_HOME/demo/schema/human_resources.

You need to call only one script, hr_main.sql, to create all the objects and load the data

Running hr_main.sql accomplishes the following tasks:

  1. Removes any previously installed HR schema
  2. Creates user HR and grants the necessary privileges
  3. Connects as HR
  4. Calls the scripts that create and populate the schema objects