概要
前回、Oracle Databaseをインストールしましたが、デフォルトでは下記の通りHuman Resources(HR)スキーマを作成するスクリプトが配置されています。
しかしながら、その他(SHやOE)のスクリプトは入っていませんでした。
/opt/oracle/product/12.2.0.1/dbhome_1/demo/schema
[oracle@aaeca05e3663 schema]$ ll
total 60
-rw-r--r-- 1 oracle oinstall 2322 Apr 3 2009 drop_sch.sql
drwxr-xr-x 2 oracle oinstall 205 May 4 06:55 human_resources
drwxr-xr-x 2 oracle oinstall 6 May 4 06:58 log
-rw-r--r-- 1 oracle oinstall 1836 May 4 06:59 mk_dir.sql
-rw-r--r-- 1 oracle oinstall 1685 Nov 6 2015 mk_dir.sql.sbs
-rw-r--r-- 1 oracle oinstall 27570 Jul 1 2014 mkplug.sql
-rw-r--r-- 1 oracle oinstall 16894 Jul 1 2014 sted_mkplug.sql.dbl
今後、色々試行錯誤するのにその他のサンプルスキーマも必要と考えられたためインストールしてみました。
環境情報
- ホストOS:Windows 10
- VirtualBox:Ver 5.2.8
- ゲストOS:CentOS 7 64bit
- コンテナOS:Oracle Linux 7.5
- Oracle:Oracle Database EE 12.2.0.1
スクリプトの場所
https://github.com/oracle/db-sample-schemas/releases/tag/v12.2.0.1
事前に上記よりOracle Database 12.2.0.1 Sample Schemasを作成するスクリプトをダウンロードしています。
ダウンロードファイル:db-sample-schemas-12.2.0.1.zip
コンテナ内のスクリプト配置場所
/home/oracle
■ダウンロードファイルの解凍
/home/oracle
[oracle@aaeca05e3663 ~]$ ll
total 36516
-rw-rw-r-- 1 oracle oinstall 37389564 May 6 05:41 db-sample-schemas-12.2.0.1.zip
lrwxrwxrwx 1 oracle oinstall 26 May 4 07:00 setPassword.sh -> /opt/oracle/setPassword.sh
[oracle@aaeca05e3663 ~]$ unzip db-sample-schemas-12.2.0.1.zip
Archive: db-sample-schemas-12.2.0.1.zip
99049719d53c2e0810b7a8462965636b98161131
creating: db-sample-schemas-12.2.0.1/
inflating: db-sample-schemas-12.2.0.1/CONTRIBUTING.md
inflating: db-sample-schemas-12.2.0.1/LICENSE.md
inflating: db-sample-schemas-12.2.0.1/README.md
inflating: db-sample-schemas-12.2.0.1/README.txt
creating: db-sample-schemas-12.2.0.1/bus_intelligence/
inflating: db-sample-schemas-12.2.0.1/bus_intelligence/bi_main.sql
inflating: db-sample-schemas-12.2.0.1/bus_intelligence/bi_oe_pr.sql
inflating: db-sample-schemas-12.2.0.1/bus_intelligence/bi_sh_pr.sql
inflating: db-sample-schemas-12.2.0.1/bus_intelligence/bi_views.sql
inflating: db-sample-schemas-12.2.0.1/shipping/qs_es.sql
inflating: db-sample-schemas-12.2.0.1/shipping/qs_main.sql
inflating: db-sample-schemas-12.2.0.1/shipping/qs_os.sql
inflating: db-sample-schemas-12.2.0.1/shipping/qs_run.sql
inflating: db-sample-schemas-12.2.0.1/shipping/qs_ws.sql
total 36520
drwxr-xr-x 9 oracle oinstall 4096 May 18 2016 db-sample-schemas-12.2.0.1
-rw-rw-r-- 1 oracle oinstall 37389564 May 6 05:41 db-sample-schemas-12.2.0.1.zip
lrwxrwxrwx 1 oracle oinstall 26 May 4 07:00 setPassword.sh -> /opt/oracle/setPassword.sh
[oracle@aaeca05e3663 ~]$ cd db-sample-schemas-12.2.0.1
[oracle@aaeca05e3663 db-sample-schemas-12.2.0.1]$ ls
CONTRIBUTING.md README.md bus_intelligence human_resources mk_dir.sql mksample.sql mkverify.sql product_media shipping
LICENSE.md README.txt drop_sch.sql info_exchange mkplug.sql mkunplug.sql order_entry sales_history
■READMEファイルの確認
README.txt
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:
placeholder names inside "<" and ">" brackets:
SYS: <SYS_password>
HR: <HR_password>
OE: <OE_password>
PM: <PM_password>
IX: <IX_password>
SH: <SH_password>
BI: <BI_password>
tablespace, and the log file directory. For illustration purposes,
the values are:
temporary tablespace: TEMP
log file directory: $ORACLE_HOME/demo/schema/log
purposes, the value of <connect_string> for database pdb is:
schema directory, the sample schema files must be
extracted on and mksample executed on the host
containing the database.
in Sections 2.1, 2.2, and 2.3 the command would look like this:
<HR_password> <OE_password> <PM_password> <IX_password>
<SH_password> <BI_password> EXAMPLE TEMP
$ORACLE_HOME/demo/schema/log/ localhost:1521/pdb
# Oracle Database Sample Schemas
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:
cd $HOME
git clone https://github.com/oracle/db-sample-schemas.git
unzip db-sample-schemas.zip
```
cd $HOME/db-sample-schemas
```
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`
perl -p -i.bak -e 's#__SUB__CWD__#'$(pwd)'#g' *.sql */*.sql */*.dat
```
source /usr/local/bin/oraenv
```
loading of the Product Media (PM) and Sales History (SH) schemas.
pre-requirements. In particular, verify your default and temporary
tablespace names, and choose a password for each schema.
discussed in [README.txt](#README.txt):
sqlplus system/systempw@connect_string
@mksample systempw syspw hrpw oepw pmpw ixpw shpw bipw users temp /your/path/to/log/ connect_string
```
■README内の手順実行
■EXAMPLESスキーマ用表領域作成
Connected.
SQL> alter session set container=pdb1;
---------- ------------------------------ ---------- ----------
3 PDB1 READ WRITE NO
SQL> set line 300
SQL> set pages 10000
SQL> col TABLESPACE_NAME for a20
SQL> col FILE_NAME for a60
SQL> select f.file_id,f.tablespace_name,f.file_name,f.bytes,f.blocks,f.autoextensible
2 from dba_tablespaces t,dba_data_files f
3 where t.tablespace_name = f.tablespace_name
4 order by f.file_id;
---------- -------------------- ------------------------------------------------------------ ---------- ---------- ---
9 SYSTEM /opt/oracle/oradata/orcl/pdb1/system01.dbf 272629760 33280 YES
10 SYSAUX /opt/oracle/oradata/orcl/pdb1/sysaux01.dbf 377487360 46080 YES
11 UNDOTBS1 /opt/oracle/oradata/orcl/pdb1/undotbs01.dbf 104857600 12800 YES
12 USERS /opt/oracle/oradata/orcl/pdb1/users01.dbf 5242880 640 YES
SQL> create tablespace examples
2 datafile '/opt/oracle/oradata/orcl/pdb1/examples.dbf'
3 size 1G
4 autoextend on maxsize unlimited;
■スキーマ作成
drwxr-xr-x 9 oracle oinstall 4096 May 6 06:49 .
drwx------ 1 oracle oinstall 124 May 6 06:45 ..
-rw-r--r-- 1 oracle oinstall 117 May 18 2016 CONTRIBUTING.md
-rw-r--r-- 1 oracle oinstall 1050 May 18 2016 LICENSE.md
-rw-r--r-- 1 oracle oinstall 4931 May 18 2016 README.md
-rw-r--r-- 1 oracle oinstall 5263 May 18 2016 README.txt
drwxr-xr-x 2 oracle oinstall 180 May 6 06:49 bus_intelligence
-rw-r--r-- 1 oracle oinstall 3633 May 6 06:49 drop_sch.sql
-rw-r--r-- 1 oracle oinstall 3633 May 18 2016 drop_sch.sql.bak
drwxr-xr-x 2 oracle oinstall 4096 May 6 06:49 human_resources
drwxr-xr-x 2 oracle oinstall 168 May 6 06:49 info_exchange
-rw-r--r-- 1 oracle oinstall 2821 May 6 06:49 mk_dir.sql
-rw-r--r-- 1 oracle oinstall 2740 May 18 2016 mk_dir.sql.bak
-rw-r--r-- 1 oracle oinstall 27972 May 6 06:49 mkplug.sql
-rw-r--r-- 1 oracle oinstall 27756 May 18 2016 mkplug.sql.bak
-rw-r--r-- 1 oracle oinstall 7463 May 6 06:49 mksample.sql
-rw-r--r-- 1 oracle oinstall 7166 May 18 2016 mksample.sql.bak
-rw-r--r-- 1 oracle oinstall 6592 May 6 06:49 mkunplug.sql
-rw-r--r-- 1 oracle oinstall 6592 May 18 2016 mkunplug.sql.bak
-rw-r--r-- 1 oracle oinstall 6123 May 6 06:49 mkverify.sql
-rw-r--r-- 1 oracle oinstall 6123 May 18 2016 mkverify.sql.bak
drwxr-xr-x 3 oracle oinstall 8192 May 6 06:49 order_entry
drwxr-xr-x 2 oracle oinstall 4096 May 6 06:49 product_media
drwxr-xr-x 2 oracle oinstall 4096 May 6 06:49 sales_history
drwxr-xr-x 2 oracle oinstall 4096 May 6 06:49 shipping
--スクリプト実行(XXXXXXXXの部分にはパスワード入力)
※ターミナルログ上、トランザクションの実行/COMMITは実行されているものの色々エラーが出力されているように見えます。
■事後確認
------------------------------------------------------------------------------------------
SYS
SYSTEM
XS$NULL
LBACSYS
OUTLN
DBSNMP
SPATIAL_CSW_ADMIN_USR
HR
BI
OE
PM
IX
SH
SQL> conn hr/XXXXXXXX@//localhost:1521/pdb1
SQL> set line 1000
SQL> set pages 2000
SQL> col TNAME for a30
SQL> select * from tab
------------------------------ ------- ----------
COUNTRIES TABLE
DEPARTMENTS TABLE
EMPLOYEES TABLE
EMP_DETAILS_VIEW VIEW
JOBS TABLE
JOB_HISTORY TABLE
LOCATIONS TABLE
REGIONS TABLE
Connected.
SQL> select * from tab;
------------------------------ ------- ----------
CAL_MONTH_SALES_MV TABLE
CHANNELS TABLE
COSTS TABLE
COUNTRIES TABLE
CUSTOMERS TABLE
DR$SUP_TEXT_IDX$I TABLE
DR$SUP_TEXT_IDX$K TABLE
DR$SUP_TEXT_IDX$N TABLE
DR$SUP_TEXT_IDX$R TABLE
DR$SUP_TEXT_IDX$U TABLE
FWEEK_PSCAT_SALES_MV TABLE
PRODUCTS TABLE
PROFITS VIEW
PROMOTIONS TABLE
SALES TABLE
SALES_TRANSACTIONS_EXT TABLE
SUPPLEMENTARY_DEMOGRAPHICS TABLE
TIMES TABLE
参考資料
https://github.com/oracle/db-sample-schemas/releases/tag/v12.2.0.1
https://github.com/oracle/db-sample-schemas/releases/tag/v12.2.0.1
https://github.com/oracle/db-sample-schemas/releases/tag/v12.2.0.1