pranphy
pranphy

Reputation: 1889

No usename HR in Oracle 12c

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.

Upvotes: 10

Views: 22642

Answers (3)

Lalit Kumar B
Lalit Kumar B

Reputation: 49092

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

Upvotes: 9

Bjarte Brandt
Bjarte Brandt

Reputation: 4471

In order to install the sample schemas, you need to follow the instructions from https://github.com/oracle/db-sample-schemas.

Anything from the original Oracle Database 12.1.0.2 demo-folder does not work properly.

Upvotes: 2

Moudiz
Moudiz

Reputation: 7377

you should unlock the HR user , connect to SQL and run this command

ALTER USER HR ACCOUNT UNLOCK IDENTIFIED BY password;

read more about it in the document

Upvotes: 2

Related Questions