Skip to content

Commit

Permalink
Oracle Database's Sample Schema creation scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
cjbj committed Jan 22, 2015
0 parents commit c503824
Show file tree
Hide file tree
Showing 397 changed files with 2,328,043 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*Due to widespread dependence on these scripts in their current form,
no pull requests for changes can be accepted.*
20 changes: 20 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2015 Oracle

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
152 changes: 152 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# Oracle Database Sample Schemas

Copyright (c) 2015 Oracle

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

## 1. Introduction

This repository contains a copy of the Oracle Database sample schemas
that are installed with Oracle Database Enterprise Edition 12c. These
schemas are used in Oracle documentation to show SQL language
concepts. The schemas themselves are documented in
[Oracle Database Sample Schemas, 12c Release 1 (12.1)](http://docs.oracle.com/database/121/COMSC/toc.htm).

The schemas are:

- HR: Human Resources
- OE: Order Entry
- PM: Product Media
- IX: Information Exchange
- SH: Sales History
- BI: Business Intelligence

*Due to widespread dependence on these scripts in their current form,
no pull requests for changes can be accepted.*

## 2. Installing the Samples

*CAUTION*: Do not use install the samples if you already have user
accounts named HR, OE, PM, IX, SH or BI.

The installation scripts are designed to run on a database host with
Oracle Database 12.1, non CDB. Privileged database access is required
during installation.

The instructions below work on Linux and similar operating systems.
Adjust them for other platforms.

An alternative to using this repository is to download and install the
[Oracle Database 12c Release 1 Examples](http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index-092322.html)
package for your platform.

### 2.1. Clone this repository

Login as the Oracle Database software owner and clone the repository, for example

```shell
cd $HOME
git clone https://github.com/oracle/db-sample-schemas.git
```

or download and extract the ZIP file:

```shell
unzip db-sample-schemas.zip
```

The schema directory should be owned by the Oracle Database software owner.

### 2.2. Change directory

```shell
cd $HOME/db-sample-schemas
```

### 2.3. Make a log directory

```shell
mkdir log
```

### 2.4. Change all embedded paths to match your working directory

The installation scripts need your current directory embedded in
various locations. Use a text editor or the following Perl script to
make the changes, replacing occurrences of the token `__SUB__CWD__`
with your current working directory, for example
`/home/oracle/db-sample-schemas`

```shell
perl -p -i.bak -e 's#__SUB__CWD__#'$(pwd)'#g' *.sql */*.sql */*.dat
```

### 2.5. Set the Oracle environment

```shell
source /usr/local/bin/oraenv
```

*Note*: Oracle's `sqlldr` utility needs to be in `$PATH` for correct
loading of the Product Media (PM) and Sales History (SH) schemas.

### 2.6. Run the installation script

Review the [README.txt](#README.txt) for information on passwords and
pre-requirements. In particular, verify your default and temporary
tablespace names, and choose a password for each schema.

Start SQL*Plus and run the top level installation script as
discussed in [README.txt](#README.txt):

```shell
sqlplus system/systempw
@mksample systempw syspw hrpw oepw pmpw ixpw shpw bipw users temp /your/path/to/log/
```

*Note: Use an absolute path and also append a trailing slash to the log directory name.*

Use your current SYSTEM and SYS passwords, and also your actual
default and temporary tablespace names. The passwords for the new
HR, OE, PM, IX, SH and BI users will be set to the values you
specify.

### 2.7. Review the installation logs

Review output in your log directory for errors.

## 3. Removing the Samples

*CAUTION*: This will drop user accounts named HR, OE, PM, IX, SH and BI.

### 3.1. Set the Oracle environment

```
source /usr/local/bin/oraenv
```

### 3.>2. Run the schema removal script

```
sqlplus system/systempw
@drop_sch.sql
```

When prompted, enter the SYSTEM password and a log file name.
159 changes: 159 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
README.txt

Created 25-NOV-2003

Updated 25-FEB-2013

Copyright (c) 2015 Oracle

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

------------------------------------------------------------------------


This document describes the structure of the Schema directory, and

provides instructions for creating the Sample Schemas.

========================================================================

1. Structure of the Schemas directory

1.1 The Schema directory contains the following files:

1.1.1 mksample.sql
This script erases and recreates all Sample Schemas.
CAUTION: This script contains directory paths that may
work only for one specific installation.

1.1.2 README.txt
This file explains the process of creating Sample Schemas.

1.2 The following folders contain scripts to DROP and CREATE database
objects, and for loading data. These scripts are called by
the mksample.sql script.

1.2.1 human_resources

1.2.1.1 The hr_main.sql script creates or recreates the HR schema.

1.2.1.2 The hr_drop.sql script drops all objects of the schema, but
does not remove the HR user.

1.2.2 order_entry

1.2.2.1 The oe_main.sql script creates or recreates the OE schema.

1.2.2.2 The oe_drop.sql script drops all relational objects, but
does not remove the OE user.

1.2.3 product_media

1.2.3.1 The pm_main.sql script creates or recreates the PM schema.

1.2.3.2 The pm_drop.sql script drops all objects, but does not
remove the PM user.

1.2.4 info_exchange

1.2.4.1 The ix_main.sql script creates or recreates the IX schema.

1.2.4.2 The dix_v3.sql script drops all objects, but does not remove
the IX user.

1.2.5 sales_history

1.2.5.1 The sh_main.sql script creates or recreates the SH schema.

1.2.5.2 The sh_drop.sql script drops all objects, but does not remove
the SH user

1.2.6 bus_intelligence

1.2.6.1 The bi_main.sql creates user BI and grants SELECT
privileges on specific OE and SH objects.

========================================================================


2. Instructions to create the schemas:


2.1 Decide on passwords for the Sample Schemas. Here, we are using
placeholder names inside "<" and ">" brackets:

SYSTEM: <SYSTEM_password>
SYS: <SYS_password>
HR: <HR_password>
OE: <OE_password>
PM: <PM_password>
IX: <IX_password>
SH: <SH_password>
BI: <BI_password>

2.2 Verify the value for the default tablespace, the temporary
tablespace, and the log file directory. For illustration purposes,
the values are:

default tablespace: EXAMPLE
temporary tablespace: TEMP
log file directory: $ORACLE_HOME/demo/schema/log

NOTE: Use your own passwords.


2.3 Invoke the Sample Schema creation script. Using the values listed
in Sections 2.1 and 2.2, the command would look like this:

SQL> @?/demo/schema/mksample <SYSTEM_password> <SYS_password>
<HR_password> <OE_password> <PM_password> <IX_password>
<SH_password> <BI_password> EXAMPLE TEMP
$ORACLE_HOME/demo/schema/log/

The mksample script lists all the objects created in the data dictionary.

========================================================================

3. Schema dependencies and requirements:

3.1 The OE schema requires that the database be enabled for spatial data
and that the HR schema exists.

3.2 The PM schema requires that the database be enabled for Intermedia,
which itself requires a Java-enabled database, and that the OE
schema exists.

3.3 The SH schema uses Partitioning and requires that the OE schema
exists.

3.4 The BI schema requires that the OE schema exists.

3.5 Refer to Oracle Database documentation for more detailed
information about the Sample Schemas.

========================================================================

4. Known bugs

4.1 The Sample Schema scripts do not work with pluggable databases.

========================================================================


Loading

0 comments on commit c503824

Please sign in to comment.