この章では、Oracle Databaseサンプル・スキーマの生成に使用するスクリプトについて説明します。この章は次の項で構成されています。
サンプル・スキーマ・スクリプトのディレクトリは、$ORACLE_HOME
/demo
/schema
です。Oracle Database Examplesメディアをインストールして、サンプル・スキーマ・スクリプトが含まれるディレクトリを移入する必要があります。各スキーマには、次の2つの主要スクリプトがあります。
xx
_main.sql
スクリプト(xx
はスキーマの略称)は、あるスキーマのすべてのオブジェクトとデータを再設定して作成します。この主となるスクリプトは、他のすべてのスクリプトを実行して、スキーマを作成およびロードします。
スクリプトxx
_drop.sql
(xx
はスキーマの略称)は、あるスキーマのすべてのオブジェクトを削除します。
Oracle Database Examplesのインストールの完了後、サンプル・スキーマ・スクリプトのディレクトリは、$ORACLE_HOME/
demo/schema
ディレクトリに格納されます。
注意: この章には、サンプル・スキーマ環境全体のマスター・スクリプトのみが記載されています。これらのスクリプトは非常に長いため、個々のスキーマのスクリプトは記載されていません。 |
マスター・スクリプトmksample.sql
によって、サンプル・スキーマ環境が設定され、すべてのスキーマが作成されます。
注意: 後述のマスター・スクリプト(mksample.sql )では、%s_pmPath% 、%s_logPath% 、%s_shPath% などの変数が使用されています。これらの変数は、インストール時にインスタンス化されます。 |
mksample.sql
スクリプトの内容は次のとおりです。
Rem Rem $Header: mksample.sql.sbs 02-apr-2003.14:55:17 $ Rem Rem mksample.sql Rem Rem Copyright (c) 2001, 2003, Oracle Corporation. All rights reserved. Rem Rem NAME Rem mksample.sql - creates all 5 Sample Schemas Rem Rem DESCRIPTION Rem This script rees and creates all Schemas belonging Rem to the Oracle Database 10g Sample Schemas. Rem If you are unsure about the prerequisites for the Sample Schemas, Rem please use the Database Configuration Assistant DBCA to Rem configure the Sample Schemas. Rem Rem NOTES Rem - OUI instantiates this script during install and saves it Rem as mksample.sql. The instantiated scripts matches Rem the directory structure on your system Rem - Tablespace EXAMPLE created with: Rem CREATE TABLESPACE example Rem NOLOGGING Rem DATAFILE '<filename>' SIZE 150M REUSE Rem AUTOEXTEND ON NEXT 640k Rem MAXSIZE UNLIMITED Rem EXTENT MANAGEMENT LOCAL Rem SEGMENT SPACE MANAGEMENT AUTO; Rem Rem - CAUTION: This script will erase the following schemas: Rem - HR Rem - OE Rem - PM Rem - SH Rem - IX Rem - BI Rem - CAUTION: Never use the preceding Sample Schemas for Rem anything other than demos and examples Rem - USAGE: To return the Sample Schemas to their initial Rem state, you can call this script and pass the passwords Rem for SYS, SYSTEM and the schemas as parameters. Rem Example: @?/demo/schema/mksample mgr secure h1 o2 p3 q4 s5 Rem (please choose your own passwords for security purposes) Rem Rem MODIFIED (MM/DD/YY) Rem Rem SET FEEDBACK 1 SET NUMWIDTH 10 SET LINESIZE 80 SET TRIMSPOOL ON SET TAB OFF SET PAGESIZE 999 SET ECHO OFF SET CONCAT '.' SET SHOWMODE OFF PROMPT PROMPT specify password for SYSTEM as parameter 1: DEFINE password_system = &1 PROMPT PROMPT specify password for SYS as parameter 2: DEFINE password_sys = &2 PROMPT PROMPT specify password for HR as parameter 3: DEFINE password_hr = &3 PROMPT PROMPT specify password for OE as parameter 4: DEFINE password_oe = &4 PROMPT PROMPT specify password for PM as parameter 5: DEFINE password_pm = &5 PROMPT PROMPT specify password for IX as parameter 6: DEFINE password_ix = &6 PROMPT PROMPT specify password for SH as parameter 7: DEFINE password_sh = &7 PROMPT PROMPT specify password for BI as parameter 8: DEFINE password_bi = &8 PROMPT PROMPT specify default tablespace as parameter 9: DEFINE default_ts = &9 PROMPT PROMPT specify temporary tablespace as parameter 10: DEFINE temp_ts = &10 PROMPT PROMPT specify log file directory (including trailing delimiter) as parameter 11: DEFINE logfile_dir = &11 PROMPT PROMPT Sample Schemas are being created ... PROMPT DEFINE vrs = v3 CONNECT system/&&password_system DROP USER hr CASCADE; DROP USER oe CASCADE; DROP USER pm CASCADE; DROP USER ix CASCADE; DROP USER sh CASCADE; DROP USER bi CASCADE; CONNECT system/&&password_system SET SHOWMODE OFF @?/demo/schema/human_resources/hr_main.sql &&password_hr &&default_ts &&temp_ts &&password_sys &&logfile_dir CONNECT system/&&password_system SET SHOWMODE OFF @?/demo/schema/order_entry/oe_main.sql &&password_oe &&default_ts &&temp_ts &&password_hr &&password_sys %s_oePath% &&logfile_dir &vrs CONNECT system/&&password_system SET SHOWMODE OFF @?/demo/schema/product_media/pm_main.sql &&password_pm &&default_ts &&temp_ts &&password_oe &&password_sys %s_pmPath% &&logfile_dir %s_pmPath% CONNECT system/&&password_system SET SHOWMODE OFF @?/demo/schema/info_exchange/ix_main.sql &&password_ix &&default_ts &&temp_ts &&password_sys &&logfile_dir &vrs CONNECT system/&&password_system SET SHOWMODE OFF @?/demo/schema/sales_history/sh_main &&password_sh &&default_ts &&temp_ts &&password_sys %s_shPath% &&logfile_dir &vrs CONNECT system/&&password_system SET SHOWMODE OFF @?/demo/schema/bus_intelligence/bi_main &&password_bi &&default_ts &&temp_ts &&password_sys &&password_oe &&password_sh &&logfile_dir &vrs CONNECT system/&&password_system SPOOL OFF DEFINE veri_spool = &&logfile_dir.mkverify_&vrs..log @?/demo/schema/mkverify &&password_system &veri_spool EXIT
この項では、Human Resources (HR
)スキーマを作成するスクリプトの名前と、スキーマで使用するオブジェクトについて説明します。表5-1に、HR
スクリプトをアルファベット順に示します。また、表5-2に、そのオブジェクトを示します。
表5-1 HRスキーマのスクリプト
スクリプト名 | 説明 |
---|---|
|
スキーマの表の統計を収集します。 |
|
スキーマのプロシージャ・オブジェクトを作成します。 |
|
スキーマのプロシージャ・オブジェクトを作成します。 |
|
|
|
|
|
|
|
|
|
|
|
|
|
オブジェクトを移入します。 |
表5-2 HRオブジェクト
オブジェクト・タイプ | オブジェクト |
---|---|
索引 |
|
プロシージャ |
|
順序 |
|
表 |
|
トリガー |
|
ビュー |
|
この項では、HRスキーマの各表の列について、次のように説明します。
表5-3 HR.COUNTRIES表の説明
列名 | Null? | 型 |
---|---|---|
|
|
|
|
|
|
|
|
|
表5-4 HR.DEPARTMENTS表の説明
列名 | Null? | 型 |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
表5-5 HR.EMPLOYEES表の説明
列名 | Null? | 型 |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
表5-6 HR.JOBS表の説明
列名 | Null? | 型 |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
表5-7 HR.JOB_HISTORY表の説明
列名 | Null? | 型 |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
この項では、Order Entry (OE)スキーマを作成するスクリプトの名前と、スキーマで使用するオブジェクトについて説明します。表5-10に、OE
スクリプトをアルファベット順に示します。また、表5-11に、そのオブジェクトを示します。製品名および説明に関する言語ごとの文は、次のファイルに格納されています(各ファイル名は、異なる言語を表します)。INSERT
oe_p_us.sql
oe_p_ar.sql
、oe_p_cs.sql
、oe_p_d.sql
、oe_p_dk.sql
、oe_p_e.sql
、oe_p_el.sql
、oe_p_esa.sql
、oe_p_f.sql
、oe_p_frc.sql
、oe_p_hu.sql
、oe_p_i.sql
、oe_p_iw.sql
、oe_p_ja.sql
、oe_p_ko.sql
、oe_p_n.sql
、oe_p_nl.sql
、oe_p_pl.sql
、oe_p_pt.sql
、oe_p_ptb.sql
、oe_p_ro.sql
、oe_p_ru.sql
、oe_p_s.sql
、oe_p_sf.sql
、oe_p_sk.sql
、oe_p_th.sql
、oe_p_tr.sql
、oe_p_zhs.sql
、oe_p_zht.sql
.
表5-10 OEスキーマのスクリプト
スクリプト名 | 説明 |
---|---|
|
可能な場合は、Online Catalog( |
|
|
|
|
|
|
|
オブジェクト表を移入します。 |
|
|
|
スキーマのオブジェクトにコメントを作成します。 |
|
|
|
|
|
|
|
|
|
|
表5-11 HRオブジェクト
オブジェクト・タイプ | オブジェクト |
---|---|
索引 |
|
ファンクション |
|
順序 |
|
LOB |
|
シノニム |
|
表 |
|
トリガー |
|
タイプ |
|
タイプ本体 |
|
ビュー |
|
この項では、OEスキーマの各表の列について、次のように説明します。
表5-12 OE.CUSTOMERS表の説明
列名 | Null? | 型 |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
表5-13 OE.INVENTORIES表の説明
列名 | Null? | 型 |
---|---|---|
|
|
|
|
|
|
|
|
|
表5-14 OE.ORDERS表の説明
列名 | Null? | 型 |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
表5-15 OE.ORDER_ITEMS表の説明
列名 | Null? | 型 |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
表5-16 OE.PRODUCT_DESCRIPTIONS表の説明
列名 | Null? | 型 |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
表5-17 OE.PRODUCT_INFORMATION表の説明
列名 | Null? | 型 |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
この項では、Product Media (PM)スキーマを作成するスクリプトの名前と、スキーマで使用するオブジェクトについて説明します。表5-19に、OEスクリプトをアルファベット順に示します。また、表5-20に、そのオブジェクトを示します。SQL*Loaderのデータ・ファイルpm_p_lob.dat
では、インストール中に設定された絶対パス名がハードコードされていることに注意してください。データを異なる環境にロードする場合は、最初にこのファイル内のパス名を編集する必要があります。
表5-19 PMスキーマのスクリプト
スクリプト名 | 説明 |
---|---|
|
|
|
|
|
|
|
スキーマのオブジェクトを移入します。 |
|
|
表5-20 PMオブジェクト
オブジェクト・タイプ | オブジェクト |
---|---|
索引 |
|
LOB |
|
表 |
|
タイプ |
|
この項では、PMスキーマの各表の列について、次のように説明します。
表5-21 PM.ONLINE_MEDIA表の説明
列名 | Null? | 型 |
---|---|---|
|
|
|
|
|
|
|
|
この型の |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
この項では、Information Exchange (IX
)スキーマを作成するスクリプトの名前と、スキーマのオブジェクトについて説明します。表5-23に、IX
スクリプトをアルファベット順に示します。また、表5-24に、そのオブジェクトを示します。
表5-23 Information Exchange(IX)スキーマのスクリプト
スクリプト名 | 説明 |
---|---|
|
|
|
|
|
|
|
|
表5-24 IXオブジェクト
オブジェクト・タイプ | オブジェクト |
---|---|
評価コンテキスト |
|
索引 |
|
LOB |
|
キュー |
|
ルール・セット |
|
順序 |
|
表 |
|
タイプ |
|
ビュー |
|
この項では、IXスキーマの各表の列について、次のように説明します。
表5-25 IX.ORDERS_QUEUETABLE表の説明
列名 | Null? | 型 |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
表5-26 IX.STREAMS_QUEUE_TABLE表の説明
列名 | Null? | 型 |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
この項では、Sales History (SH)スキーマを作成するスクリプトの名前と、スキーマで使用するオブジェクトについて説明します。表5-27に、SH
スクリプトをアルファベット順に示します。また、表5-28に、そのオブジェクトを示します。
表5-27 SHスキーマのスクリプト
スクリプト名 | 説明 |
---|---|
|
スキーマ・オブジェクトの統計を収集します。 |
|
スキーマのオブジェクトにコメントを作成します。 |
|
スキーマのオブジェクトに対する制約を変更します。 |
|
スキーマのオブジェクトを作成します。 |
|
マテリアライズド・ビューおよびビットマップ索引を作成します。 |
|
|
|
スキーマの表に索引を作成します。 |
|
|
|
OLAPサーバーで使用するディメンションおよび階層を作成します。 |
|
OLAPサーバーで使用するオブジェクトを削除します。 |
表5-28 SHオブジェクト
オブジェクト・タイプ | オブジェクト |
---|---|
ディメンション |
|
索引 |
|
索引パーティション |
|
LOB |
|
マテリアライズド・ビュー |
|
表 |
|
表パーティション |
|
ビュー |
|
この項では、IXスキーマの各表の列について、次のように説明します。
表5-29 SH.CHANNELS表の説明
列名 | Null? | 型 |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
表5-30 SH.COSTS表の説明
列名 | Null? | 型 |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
表5-31 SH.COUNTRIES表の説明
列名 | Null? | 型 |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
表5-32 SH.CUSTOMERS表の説明
列名 | Null? | 型 |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
表5-33 SH.PRODUCTS表の説明
列名 | Null? | 型 |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
表5-34 SH.PROMOTIONS表の説明
列名 | Null? | 型 |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
表5-35 SH.SALES表の説明
列名 | Null? | 型 |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
表5-36 SH.TIMES表の説明
列名 | Null? | 型 |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|