|
| 1 | +# Oracle Database Sample Schemas |
| 2 | + |
| 3 | +Copyright (c) 2015 Oracle |
| 4 | + |
| 5 | +Permission is hereby granted, free of charge, to any person obtaining |
| 6 | +a copy of this software and associated documentation files (the |
| 7 | +"Software"), to deal in the Software without restriction, including |
| 8 | +without limitation the rights to use, copy, modify, merge, publish, |
| 9 | +distribute, sublicense, and/or sell copies of the Software, and to |
| 10 | +permit persons to whom the Software is furnished to do so, subject to |
| 11 | +the following conditions: |
| 12 | + |
| 13 | +The above copyright notice and this permission notice shall be |
| 14 | +included in all copies or substantial portions of the Software. |
| 15 | + |
| 16 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 17 | +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 18 | +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 19 | +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 20 | +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 21 | +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 22 | +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 23 | + |
| 24 | +## 1. Introduction |
| 25 | + |
| 26 | +This repository contains a copy of the Oracle Database sample schemas |
| 27 | +that are installed with Oracle Database Enterprise Edition 12c. These |
| 28 | +schemas are used in Oracle documentation to show SQL language |
| 29 | +concepts. The schemas themselves are documented in |
| 30 | +[Oracle Database Sample Schemas, 12c Release 1 (12.1)](http://docs.oracle.com/database/121/COMSC/toc.htm). |
| 31 | + |
| 32 | +The schemas are: |
| 33 | + |
| 34 | +- HR: Human Resources |
| 35 | +- OE: Order Entry |
| 36 | +- PM: Product Media |
| 37 | +- IX: Information Exchange |
| 38 | +- SH: Sales History |
| 39 | +- BI: Business Intelligence |
| 40 | + |
| 41 | +*Due to widespread dependence on these scripts in their current form, |
| 42 | +no pull requests for changes can be accepted.* |
| 43 | + |
| 44 | +## 2. Installing the Samples |
| 45 | + |
| 46 | +*CAUTION*: Do not use install the samples if you already have user |
| 47 | +accounts named HR, OE, PM, IX, SH or BI. |
| 48 | + |
| 49 | +The installation scripts are designed to run on a database host with |
| 50 | +Oracle Database 12.1, non CDB. Privileged database access is required |
| 51 | +during installation. |
| 52 | + |
| 53 | +The instructions below work on Linux and similar operating systems. |
| 54 | +Adjust them for other platforms. |
| 55 | + |
| 56 | +An alternative to using this repository is to download and install the |
| 57 | +[Oracle Database 12c Release 1 Examples](http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index-092322.html) |
| 58 | +package for your platform. |
| 59 | + |
| 60 | +### 2.1. Clone this repository |
| 61 | + |
| 62 | +Login as the Oracle Database software owner and clone the repository, for example |
| 63 | + |
| 64 | +```shell |
| 65 | +cd $HOME |
| 66 | +git clone https://github.com/oracle/db-sample-schemas.git |
| 67 | +``` |
| 68 | + |
| 69 | +or download and extract the ZIP file: |
| 70 | + |
| 71 | +```shell |
| 72 | +unzip db-sample-schemas.zip |
| 73 | +``` |
| 74 | + |
| 75 | +The schema directory should be owned by the Oracle Database software owner. |
| 76 | + |
| 77 | +### 2.2. Change directory |
| 78 | + |
| 79 | +```shell |
| 80 | +cd $HOME/db-sample-schemas |
| 81 | +``` |
| 82 | + |
| 83 | +### 2.3. Make a log directory |
| 84 | + |
| 85 | +```shell |
| 86 | +mkdir log |
| 87 | +``` |
| 88 | + |
| 89 | +### 2.4. Change all embedded paths to match your working directory |
| 90 | + |
| 91 | +The installation scripts need your current directory embedded in |
| 92 | +various locations. Use a text editor or the following Perl script to |
| 93 | +make the changes, replacing occurrences of the token `__SUB__CWD__` |
| 94 | +with your current working directory, for example |
| 95 | +`/home/oracle/db-sample-schemas` |
| 96 | + |
| 97 | +```shell |
| 98 | +perl -p -i.bak -e 's#__SUB__CWD__#'$(pwd)'#g' *.sql */*.sql */*.dat |
| 99 | +``` |
| 100 | + |
| 101 | +### 2.5. Set the Oracle environment |
| 102 | + |
| 103 | +```shell |
| 104 | +source /usr/local/bin/oraenv |
| 105 | +``` |
| 106 | + |
| 107 | +*Note*: Oracle's `sqlldr` utility needs to be in `$PATH` for correct |
| 108 | +loading of the Product Media (PM) and Sales History (SH) schemas. |
| 109 | + |
| 110 | +### 2.6. Run the installation script |
| 111 | + |
| 112 | +Review the [README.txt](#README.txt) for information on passwords and |
| 113 | +pre-requirements. In particular, verify your default and temporary |
| 114 | +tablespace names, and choose a password for each schema. |
| 115 | + |
| 116 | +Start SQL*Plus and run the top level installation script as |
| 117 | +discussed in [README.txt](#README.txt): |
| 118 | + |
| 119 | +```shell |
| 120 | +sqlplus system/systempw |
| 121 | +@mksample systempw syspw hrpw oepw pmpw ixpw shpw bipw users temp /your/path/to/log/ |
| 122 | +``` |
| 123 | + |
| 124 | +*Note: Use an absolute path and also append a trailing slash to the log directory name.* |
| 125 | + |
| 126 | +Use your current SYSTEM and SYS passwords, and also your actual |
| 127 | +default and temporary tablespace names. The passwords for the new |
| 128 | +HR, OE, PM, IX, SH and BI users will be set to the values you |
| 129 | +specify. |
| 130 | + |
| 131 | +### 2.7. Review the installation logs |
| 132 | + |
| 133 | +Review output in your log directory for errors. |
| 134 | + |
| 135 | +## 3. Removing the Samples |
| 136 | + |
| 137 | +*CAUTION*: This will drop user accounts named HR, OE, PM, IX, SH and BI. |
| 138 | + |
| 139 | +### 3.1. Set the Oracle environment |
| 140 | + |
| 141 | +``` |
| 142 | +source /usr/local/bin/oraenv |
| 143 | +``` |
| 144 | + |
| 145 | +### 3.>2. Run the schema removal script |
| 146 | + |
| 147 | +``` |
| 148 | +sqlplus system/systempw |
| 149 | +@drop_sch.sql |
| 150 | +``` |
| 151 | + |
| 152 | +When prompted, enter the SYSTEM password and a log file name. |
0 commit comments