How to create the sample HR schema in your PDB?

Let’s create the sample schema HR in a new PDB

Step 1 ) Navigate to the DEMO folder

[oracle@ggs1 ~]$ cd /u01/app/oracle/product/19c/dbhome_1/demo/schema/human_resources
[oracle@ggs1 human_resources]$
[oracle@ggs1 human_resources]$ ls -ltr
total 100
-rw-r--r--. 1 oracle oinstall 1345 Aug 29 2002 hr_idx.sql
-rw-r--r--. 1 oracle oinstall 7186 Aug 29 2002 hr_comnt.sql
-rw-r--r--. 1 oracle oinstall 9381 Aug 29 2002 hr_cre.sql
-rw-r--r--. 1 oracle oinstall 2733 Aug 29 2002 hr_code.sql
-rw-r--r--. 1 oracle oinstall 1132 Oct 12 2002 hr_analz.sql
-rw-r--r--. 1 oracle oinstall 44288 Aug 15 2008 hr_popul.sql
-rw-r--r--. 1 oracle oinstall 5046 Nov 6 2015 hr_main_new.sql
-rw-r--r--. 1 oracle oinstall 2609 Nov 6 2015 hr_drop_new.sql
-rw-r--r--. 1 oracle oinstall 4755 Mar 30 2016 hr_main.sql
-rw-r--r--. 1 oracle oinstall 2611 Mar 30 2016 hr_drop.sql

Step 2 ) Connect to the PDB and execute the “hr_main.sql”

This is going to create the HR user into the PDB

[oracle@ggs1 human_resources]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Thu Aug 18 08:08:14 2022
Version 19.14.0.0.0

Copyright (c) 1982, 2021, Oracle.  All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.14.0.0.0

SQL> show pdbs

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 2 PDB$SEED			  READ ONLY  NO
	 3 ORCLPDB			  READ WRITE NO
SQL> alter session set container=ORCLPDB;

Session altered.

SQL> @hr_main.sql

specify password for HR as parameter 1:
Enter value for 1: hr

specify default tablespeace for HR as parameter 2:
Enter value for 2: users

specify temporary tablespace for HR as parameter 3:
Enter value for 3: temp

specify log path as parameter 4:
Enter value for 4: /tmp

…………………….

Comment created.


Commit complete.


PL/SQL procedure successfully completed.

Step 3 ) Let’s connect as HR and check the tables

[oracle@ggs1 human_resources]$ sqlplus hr/hr@orclpdb

Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.14.0.0.0

SQL> show user
USER is "HR"
SQL> set lin 200
SQL> col tname format a30
SQL> select * from tab;

TNAME			       TABTYPE	      CLUSTERID
------------------------------ ------------- ----------
REGIONS 		       TABLE
COUNTRIES		       TABLE
LOCATIONS		       TABLE
DEPARTMENTS		       TABLE
JOBS			       TABLE
EMPLOYEES		       TABLE
JOB_HISTORY		       TABLE
EMP_DETAILS_VIEW	       VIEW

8 rows selected.

SQL>

Leave a Reply

%d bloggers like this: