Oracle Sample Schemas in 12.2
Sometimes you need, or maybe you only want them, some of the typical schemas from Oracle like HR, SCOTT, etc… in your database, well, we are going to install all of them on Oracle 12.2.
We can see the documentation:
https://docs.oracle.com/database/122/COMSC/installing-sample-schemas.htm#COMSC001 Installing Sample Schemas from GitHub Starting with Oracle Database 12c Release 2, only the HR sample schema SQL scripts are available in the $ORACLE_HOME/demo/schema/human_resources directory. If you want to use sample schemas other than HR, such as OE, OC, PM, and SH schemas, you must download them from the GitHub repository. The procedure to install sample schemas from GitHub is as follows: To find the latest version of the sample schemas installation scripts, go to the following GitHub web site : https://github.com/oracle/db-sample-schemas/releases/latest For example, If you want a 220.127.116.11 version of the scripts, then go to https://github.com/oracle/db-sample-schemas/releases/tag/v18.104.22.168 Clone the GitHub repository, or download the ZIP bundle from GitHub and extract the files. Unzip the file. Follow the instructions to create the schemas in the README contained in the zip file.
We unzipped on a path with access from our virtual machine:
[oracle@dg1 ~]$ cd /media/sf_12.2/db-sample-schemas-22.214.171.124/ [oracle@dg1 db-sample-schemas-126.96.36.199]$ ls bus_intelligence human_resources mk_dir.sql mkunplug.sql product_media sales_history CONTRIBUTING.md info_exchange mkplug.sql mkverify.sql README.md shipping drop_sch.sql LICENSE.md mksample.sql order_entry README.txt
Very important to read the Readme.md for modifying __SUB_CWD__ inside of the scripts:
[oracle@dg1 db-sample-schemas-188.8.131.52]$ $ORACLE_HOME/perl/bin/perl -p -i.bak -e 's#__SUB__CWD__#'$(pwd)'#g' *.sql */*.sql */*.dat
We install it on a pdb:
SQL> col name format a25 SQL> select name, open_mode FROM v$pdbs; NAME OPEN_MODE ------------------------- ---------- PDB$SEED READ ONLY MADRIDPDB READ WRITE
Test the connection:
SQL> connect system/oracle@localhost:1521/madridpdb Connected.
Example in the creation:
SQL> @?/mksample <SYSTEM_password> <SYS_password> <HR_password> <OE_password> <PM_password> <IX_password> <SH_password> <BI_password> TABLESPACE_DEFAULT_USERS TABLESPACE_DEFAULT_TEMP LOG_PATH localhost:1521/pdb
We run the script:
SQL> @mksample oracle oracle hr oe pm ix sh bi USERS TEMP /media/sf_12.2/db-sample-schemas-184.108.40.206/log localhost:1521/madridpdb
Adding value with Arumel!!