How to install HR schema in Oracle XE > 18?




In Oracle XE databases up to version 12, the HR schema is available directly, you just need to unlock it.
In Oracle XE versions 12 to 18, the HR schema is available in the XEPDB1 database. We do not need to install it. You just need to log into the XEPDB1 database and unlock the HR schema as in earlier versions of the database. How to unlock the HR schema?

In Oracle XE versions above 18, the HR schema is not available at all. Therefore, we need to install it ourselves. Here's a step-by-step guide on how to install the HR schema in XE databases in versions >18.

Downloading HR Schema Scripts
Download the latest version of the HR schema from Git [source_code.zip].


Extract the file to your disk.
Go to the directory where you extracted the downloaded scripts and into the subfolder human_recources.

C:\_monika>cd C:\_monika\install\db-sample-schemas-23.3\db-sample-schemas-23.3\human_resources

Run sqlplus or sqlcl with a user that has privileges to create users (CREATE USER), for example, SYS as SYSDBA.

C:\_monika\install\db-sample-schemas-23.3\db-sample-schemas-23.3\human_resources>sqlplus sys/SYS@localhost:11521 as sysdba

Installation of the HR Schema
Run the HR schema installation: the HR_install script.
During the installation, you will be asked for a password for the user and a tablespace for the HR user. The script will also ask if you want to overwrite the HR user if it already exists in the database. [YES/NO]

SQL> @hr_install 

Logging into the HR Schema
If everything went according to plan, we can log into the HR schema!

sql hr/hr@localhost:11521/FREE

And even execute some query:
SQL> select count(*) from employees;

   COUNT(*)
___________
        107

That's it! 

Komentarze