Installing Sample Schemas ( HR Schema )
quoted from:
Starting with Oracle Database 12c Release 2, the latest version of the sample schema scripts are available on GitHub at https://github.com/oracle/db-sample-schemas/releases/latest.
During a complete installation of Oracle Database, the HR schema can be installed either manually or automatically when creating a database using the dbca
option. All the other sample schemas must be installed manually via the scripts available on GitHub.
This chapter contains the following topics:
2.1 Installing HR Schema Only
This section contains the following topics:
2.1.1 Installing HR Schema Using Database Configuration Assistant
Select the sample schemas
option to install HR
schema in the database.
At the end of the installation process, a dialog box displays the accounts that have been created and their lock status. By default, sample schemas are locked and their passwords are expired. Before you can use a locked account, you must unlock it and reset its password. You can unlock the accounts at this point in the installation process. Alternatively, after the installation completes, you can unlock the schemas and reset their passwords by using the ALTER USER ... ACCOUNT UNLOCK
statement. For example:
ALTER USER hr ACCOUNT UNLOCK IDENTIFIED BY Password;
See Also:
"Guidelines for Securing Passwords" in Oracle Database Security Guide for guidelines related to creating secure passwords
2.1.2 Manually 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. The following steps provide a summary of the installation process:
-
Log on to SQL*Plus as
SYS
andconnect
using theAS SYSDBA
privilege.sqlplus connect sys as sysdba Enter password:
password
-
To run the
hr_main.sql
script, use the following command:SQL> @?/demo/schema/human_resources/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,
users
as the default tablespace forHR
specify default tablespace for HR as parameter 2: Enter value for 2:
-
Enter
temp
as the temporary tablespace forHR
specify temporary tablespace for HR as parameter 3: Enter value for 3:
-
Enter your
SYS
passwordspecify password for SYS as parameter 4: Enter value for 4:
-
Enter the directory path, for example,
$ORACLE_HOME
/demo/schema/log/
, for your log directoryspecify log path as parameter 5: Enter value for 5:
After script hr_main.sql
runs successfully and schema HR
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
HR
schema - Creates user
HR
and 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 script hr_dn_d.sql
to undo the effects of script hr_dn_c.sql
.
You can use script hr_drop.sql
to drop schema HR
.
See Also:
Oracle Database Security Guide for the minimum password requirements
2.1.3 Uninstalling HR Schema
If you need to remove the HR schema, run the following script on the SQL* Plus command line.
sqlplus system/[email protected]_string
@drop_hr.sql