Oracle10g的 Database Examples 安装

有时候看到网上好多例子都是scott用户或hr用户下的表, 在oracle10g里, 这些demo用户放在另外一张伴侣盘里, 需要单独安装.

1. 从 oracle 网站下载Oracle10g Companion CD. 然后安装(我选择静默安装不用图形界面)

$ cd /orahome/soft/
$ rz   (SecureCRT里通过rz命令上传oracle10g Companion CD安装文件10201_companion_linux32.zip, 其它上传方式也行)
$ unzip 10201_companion_linux32.zip
$ cd /orahome/soft/companion
$ ./runInstaller -silent -responseFile /orahome/soft/companion/response/companionCD.db.rsp UNIX_GROUP_NAME="oinstall" ORACLE_HOME="/u01/app/oracle/product/10.2.0/db_1" ORACLE_HOME_NAME="OraDb10g_home1"
响应文件companionCD.db.rsp指的是Oracle Database 10g Product 10.2.0.1.0, 因Database Examples在这里, 即Oracle Database Demos 10.2.0.1.0 组件。

会安装以下组件:
   Oracle Database 10g Products 10.2.0.1.0
   Oracle JDBC Development Drivers 10.2.0.1.0
   Oracle Spatial Demos 10.2.0.1.0
   JAccelerator (COMPANION) 10.2.0.1.0
   Oracle SQLJ Demos 10.2.0.1.0
   Oracle Internet Directory Client Demos 10.2.0.1.0
   Oracle interMedia Demos 10.2.0.1.0
   Precomp Demo Files 10.2.0.1.0
   Oracle XML Demos 10.2.0.1.0
   Oracle Database Demos 10.2.0.1.0
   SQL*Plus Demos 10.2.0.1.0
   Oracle Globalization Support Demos 10.2.0.1.0
   Oracle Context Companion 10.2.0.1.0
   Oracle Ultra Search Server Rdbms 10.2.0.1.0
   Oracle Ultra Search Server 10.2.0.1.0
   Oracle Ultra Search Middle-Tier 10.2.0.1.0
   Oracle Ultra Search Common Files 10.2.0.1.0
   Perl Interpreter 5.8.3.0.2
   Oracle Workflow 2.6.4.0.0
   Oracle Workflow Manager 2.6.4.0.0

安装后Database Demos在 $ORACLE_HOME/demo/schema 目录下. Sqlplus Demo在 $ORACLE_HOME/sqlplus/demo 目录下.
$ cd $ORACLE_HOME/demo/schema
$ ll
total 128
drwxr-x--- 2 oracle oinstall 4096 Dec 10 11:06 bus_intelligence
drwxr-x--- 2 oracle oinstall 4096 Dec 10 11:06 human_resources
drwxrwx--- 2 oracle oinstall 4096 Dec 10 11:06 info_exchange
drwxr-x--- 2 oracle oinstall 4096 Dec 5 11:33 log
-rw-r----- 1 oracle oinstall 1614 Dec 10 11:06 mk_dir.sql
-rw-r----- 1 oracle oinstall 1614 Dec 5 11:33 mk_dir.sql.ouibak
-rw-r----- 1 oracle oinstall 1614 Dec 5 11:33 mk_dir.sql.ouibak.1
-rw-r----- 1 oracle oinstall 27113 May 10 2005 mkplug.sql
-rw-rw---- 1 oracle oinstall 5300 Dec 10 11:06 mksample.sql
-rw-rw---- 1 oracle oinstall 5094 Apr 3 2003 mksample.sql.sbs
-rw-rw---- 1 oracle oinstall 5076 May 10 2005 mkunplug.sql
-rw-rw---- 1 oracle oinstall 4796 Sep 23 2004 mkverify.sql
drwxr-x--- 3 oracle oinstall 4096 Dec 10 11:06 order_entry
drwxrwx--- 2 oracle oinstall 4096 Dec 10 11:06 product_media
-rw-rw---- 1 oracle oinstall 4368 Dec 8 2003 README.txt
drwxr-x--- 2 oracle oinstall 4096 Dec 10 11:06 sales_history
drwxrwx--- 2 oracle oinstall 4096 Dec 10 11:06 shipping
-rw-r----- 1 oracle oinstall 15246 May 10 2005 sted_mkplug.sql.dbl
$ cd $ORACLE_HOME/sqlplus/demo
$ ll
total 8
-rw-rw---- 1 oracle oinstall 3565 Jun 28 2000 demobld.sql
-rw-rw---- 1 oracle oinstall 573 Jun 28 2000 demodrop.sql

其中各目录和文件说明:
mksample.sql   -- script. that erases and recreates all Sample Schemas
mk_dir.sql   -- script. that sets the DIRECTORY objects. This script. is invoked during database creation by the DBCA
README.txt   -- explains the process of creating the Sample Schemas
human_resources   -- hr_main.sql creates or recreates the HR schema
       -- hr_drop.sql drops all objects, but not the HR user
order_entry   -- oe_main.sql creates or recreates the whole OE schema
       -- oe_drop.sql drops all relational objects, but not the HR user
       -- oc_main.sql creates the OC subschema and is called by oe_main.sql (OC stands for Online Catalog)
       -- oc_drop.sql drops all the object-relational parts of the OC subschema
product_media   -- pm_main.sql creates or recreates the PM schema
       -- pm_drop.sql drops all objects, but not the PM user
info_exchange   -- ix_main.sql creates or recreates the IX schema
       -- dix_v3.sql drops all objects, but not the IX user
sales_history   -- sh_main.sql creates or recreates the SH schema
       -- sh_drop.sql drops all objects, but not the SH user
bus_intelligence-- bi_main.sql creates user BI and grants SELECT privileges on specific OE and SH objects

demobld.sql   --在当前用户下新建EMP, DEPT, BONUS, SALGRADE, DUMMY这几张表
demodrop.sql   --删除当前用户下EMP, DEPT, BONUS, SALGRADE, DUMMY这几张表

各个新建用户的依赖性说明:
The HR schema does not require any other schema other than SYS and SYSTEM to be present.
The OE schema requires the database to be enabled for spatial data.
The PM schema requires the database to be enabled for Intermedia, which in turn requires a java-enabled database.
The SH schema uses Partitioning.

2. 开始安装或重建Database Demos

$ sqlplus '/as sysdba'

--新建一表空间专门存放这些用户数据
SQL> CREATE TABLESPACE ts_example NOLOGGING DATAFILE '/orahome/oradata/WENDING/ts_example01.dbf' SIZE 150M REUSE AUTOEXTEND ON NEXT 640k MAXSIZE UNLIMITED;

--全部安装这6个用户, 陆续输入8个用户密码, 默认表空间, 临时表空间, 执行日志目录
SQL> @?/demo/schema/mksample.sql

--或者指定参数执行也行
SQL> @?/demo/schema/mksample.sql systempwd syspwd hrpwd oepwd pmpwd ixpwd shpwd bipwd ts_example temp $ORACLE_HOME/demo/schema/log/
--其实大部分时候我们只要hr用户即可做各种例子了
SQL> @?/demo/schema/human_resources/hr_main.sql hrpwd ts_example temp syspwd $ORACLE_HOME/demo/schema/log/

--安装的对象信息如下
SQL> select owner,object_type,count(*)
from dba_objects
where owner in ('IX', 'SH', 'OE', 'HR', 'BI', 'PM')
group by owner,rollup(object_type)
order by 1,2;

OWNER                          OBJECT_TYPE           COUNT(*)
------------------------------ ------------------- ----------
BI                             SYNONYM                      8
BI                                                          8
HR                             INDEX                       19
HR                             PROCEDURE                    2
HR                             SEQUENCE                     3
HR                             TABLE                        7
HR                             TRIGGER                      2
HR                             VIEW                         1
HR                                                         34
IX                             EVALUATION CONTEXT           2
IX                             INDEX                       14
IX                             LOB                          3
IX                             QUEUE                        4
IX                             RULE SET                     4
IX                             SEQUENCE                     2
IX                             TABLE                       15
IX                             TYPE                         1
IX                             VIEW                         8
IX                                                         53
OE                             FUNCTION                     1
OE                             INDEX                       19
OE                             SEQUENCE                     1
OE                             SYNONYM                      6
OE                             TABLE                        9
OE                             TRIGGER                      1
OE                             TYPE                        22
OE                             TYPE BODY                    3
OE                             VIEW                         3
OE                                                         65
PM                             INDEX                        2
PM                             LOB                          7
PM                             TABLE                        2
PM                             TYPE                         3
PM                                                         14
SH                             DIMENSION                    5
SH                             INDEX                       23
SH                             INDEX PARTITION            196
SH                             MATERIALIZED VIEW            2
SH                             TABLE                       12
SH                             TABLE PARTITION             56
SH                             VIEW                         1
SH                                                        295

42 rows selected.

2. 安装或删除Sqlplus Demo

--安装
$ sqlplus u_test/iamwangnc
SQL> @?/sqlplus/demo/demobld.sql

--删除
$ sqlplus u_test/iamwangnc
SQL> @?/sqlplus/demo/demodrop.sql

--End--

猜你喜欢

转载自fengyuyaoye.iteye.com/blog/1572594