2 Installation of the Sample Schemas
Oracle provides the following sample schemas: HR, OE, OC,
            PM, and SH. You must download the installable zip file from
        the GitHub repository to use the sample schemas.
               
This section includes the following topics:
Note:
Starting with Oracle Database 21c, the HR sample schema no longer ships as part of Oracle Database. For more information, see Installing the HR Schema.2.1 Installing the Sample Schemas
The Sample Schemas can be installed together using a single script.
- To find the latest version of the sample schemas installation
                    scripts, go to the following GitHub location
                        :https://github.com/oracle/db-sample-schemas/releases/latest For example, If you want a 19.2 version of the scripts, then go to the following location:https://github.com/oracle/db-sample-schemas/releases/tag/v19.2 
- Clone the GitHub repository, or download the ZIP bundle from GitHub and extract the files.
- Use the following syntax from the SQL*Plus command-line
                    interface:sqlplus system/systempw@connect_string @mksample systempw syspw hrpw oepw pmpw ixpw shpw bipw users temp /your/path/to/log/ connect_string You can also follow the instructions in the README file contained in the zip file.The mksamplescript expects 11 parameters. Provide the password forSYSTEMandSYS, and for schemasHR,OE,PM,IX, andSH. Specify a temporary tablespace and a default tablespace, and make sure that you end the name of the log file directory with a trailing slash.
The mksample script produces the following log
                files:
                     
- 
                           
                           mkverify.log- This is the Sample Schema creation log file.
- 
                           
                           hr_main.log- This is theHRschema creation log file.
- 
                           
                           oe_oc_main.log- This is theOEschema creation log file.
- 
                           
                           pm_main.log- This is thePMschema creation log file.
- 
                           
                           pm_p_lob.log- This is the SQL*Loader log file forPM.PRINT_MEDIA.
- 
                           
                           ix_main.log- This is theIXschema creation log file.
- 
                           
                           sh_main.log- This is theSHschema creation log file.
- 
                           
                           cust.log- This is the SQL*Loader log file forSH.CUSTOMERS.
- 
                           
                           prod.log- This is the SQL*Loader log file forSH.PRODUCTS.
- 
                           
                           promo.log- This is the SQL*Loader log file forSH.PROMOTIONS.
- 
                           
                           sales.log- This is the SQL*Loader log file forSH.SALES.
- 
                           
                           sales_ext.log- This is the external table log file forSH.COSTS.
Note:
- Only HRandSHschemas can be installed independently. The rest of the schemas have dependencies and must be installed together using the@mksamplescript. See Installing the HR Schema.
- The master script @mksamplecurrently does not include the CO schema. You must install it separately. See Installing the CO schema.
- By installing any of the Oracle Database sample schemas, you drop any
                            previously installed schemas that use the following user names:
                                HR,OE,PM,SH,IX,BI,CO.
- Data contained in any of these schemas is lost if you run any of the installation scripts described in this section. You should not use the sample schemas for your personal or business data and applications. They are meant to be used for demonstration purposes only.
2.2 Installing the HR Schema
You can install the HR schema independently. All scripts necessary to create the Human
    Resource (HR) schema reside in the human_resources folder of
    the sample schema installation scripts downloaded earlier. You need to call only one script,
      hr_main.sql, to create all the objects and load the data. 
                  
Perform the following steps to install the HR schema:
                     
- Download the sample schema installation zip from GitHub and extract the files.
- Navigate to the human_resourcesfolder.
- Log on to SQL*Plus as SYSandconnectusing theAS SYSDBAprivilege:sqlplus connect sys as sysdba Enter password:password
- To run the hr_main.sqlscript, use the following command:SQL> @hr_main.sql 
- Enter a secure password for
          HR:specify password for HR as parameter 1: Enter value for 1: 
- Enter an appropriate tablespace, for example, usersas the default tablespace forHR:specify default tablespace for HR as parameter 2: Enter value for 2: 
- Enter tempas the temporary tablespace forHR:specify temporary tablespace for HR as parameter 3: Enter value for 3: 
- Enter the password for
          SYS:specify password for SYS as parameter 4: Enter value for 4: 
- Enter the directory path, for example,
            $ORACLE_HOME/demo/schema/log/, for your log directory:specify log path as parameter 5: Enter value for 5: 
After the hr_main.sql script runs successfully and the
          HR schema is installed, you are connected as user HR. To
        verify that the schema was created, use the following command:
                     
SQL> SELECT table_name FROM user_tables;
Running hr_main.sql accomplishes the following tasks:
                     
- Removes any previously installed HRschema.
- Creates user HRand grants the necessary privileges.
- Connects as HR.
- Calls the scripts that create and populate the schema objects.
For a complete listing of the scripts and their functions, refer to HR Sample Schema Scripts and Objects.
A pair of optional scripts, hr_dn_c.sql and
          hr_dn_d.sql, is provided as a schema extension. To prepare schema
          HR for use with the directory capabilities of Oracle Internet Directory,
        run the hr_dn_c.sql script. If you want to return to the initial setup of
        schema HR, use the hr_dn_d.sql script to undo the effects
        of the hr_dn_c.sql script.
                     
SQL>@hr_drop.sqlNote:
Similarly SH schema can be installed independently.See Also:
Oracle Database Security Guide for the minimum password requirements
2.3 Installing the CO schema
You can install the CO schema independently from GitHub.
        You cannot install the CO schema as part of the @mksample
        script. 
                  
The steps to install CO schema from GitHub is as
                follows:
                     
Note:
- The Customer Orders(CO) schema is available from Oracle Database 12c onwards.
- The master script @mksamplecurrently does not include theCOschema.
2.4 Resetting Sample Schemas
Typically, there is no difference between installing a Sample Schema for the
                first time or reinstalling it over a previously installed version. The
                        *_main.sql scripts drop the schema users and all of their
                objects from the previous installation.
                  
Therefore, to reset the Sample Schemas, follow the steps mentioned in the section Installing the Sample Schemas.
2.5 Uninstalling Sample Schemas
To uninstall the sample schemas, run the drop_sch.sql
                                script on the SQL*Plus command line. This script ships with Oracle
                                Database.
                  
This script uses the following parameters:
- 
                              systempwd
- 
                              SYSTEM
- 
                              connect_string
The systempwd is the password for SYSTEM user and connect_string is the connection string of the database.
                     
Example 2-1 How to Uninstall Sample Schemas
sqlplus system/systempw@connect_string @drop_sch.sql