共计 3708 个字符,预计需要花费 10 分钟才能阅读完成。
在做 Oracle 数据库实验时都会用到一些示例 SCHEMA 如:HR、OE、SH 等,在 Oracle11g 版本时在 DBCA 时直接勾选 Sample Schemas 就可以安装这些示例 SCHEMA,如下图:
但到了 Oracle12.2 版本,也有一个示例 Schemas 选项卡如下图所示:
但是数据库安装完成后却还是没有这些示例 SCHEMA,到底是怎么回事呢?我们来查一下官方文档:
Starting with Oracle Database 12c Release 2, the latest version of the sample schema scripts are available on GitHub at https://github.com/oracle/db-sample-schemas/releases/latest.
During a complete installation of Oracle Database, the HR schema can be installed either manually or automatically when creating a database using the dbca
option. All the other sample schemas must be installed manually via the scripts available on GitHub.
从上面的官方文档中我们可以看到从 Oracle12.2 版本开始,示例 Schemas 的脚本被放到了 GitHub 上,在 DBCA 安装时只会安装 hr 示例 Schema。从文档中给出的指定地址下载示例 Schema 安装脚本:
从 README.txt 文档中找到安装方法,开始安装:
sys@ORA12C>@mksample
specify password
for
SYSTEM as parameter 1:
Enter value
for
1: 123456
specify password
for
SYS as parameter 2:
Enter value
for
2: 123456
specify password
for
HR as parameter 3:
Enter value
for
3: hr
specify password
for
OE as parameter 4:
Enter value
for
4: oe
specify password
for
PM as parameter 5:
Enter value
for
5: pm
specify password
for
IX as parameter 6:
Enter value
for
6: ix
specify password
for
SH as parameter 7:
Enter value
for
7: sh
specify password
for
BI as parameter 8:
Enter value
for
8: bi
specify default tablespace as parameter 9:
Enter value
for
9:
users
specify temporary tablespace as parameter 10:
Enter value
for
10: temp
specify log
file
directory (including trailing delimiter) as parameter 11:
Enter value
for
11:
/home/oracle/dbca
specify connect string as parameter 12:
Enter value
for
12: localhost:1521
/ora12c
Sample Schemas are being created ...
mkdir
: cannot create directory‘
/home/oracle/dbca
’: File exists
Connected.
DROP USER hr CASCADE
*
ERROR at line 1:
ORA-01918: user
'HR'
does not exist
DROP USER oe CASCADE
*
ERROR at line 1:
ORA-01918: user
'OE'
does not exist
DROP USER pm CASCADE
*
ERROR at line 1:
ORA-01918: user
'PM'
does not exist
DROP USER ix CASCADE
*
ERROR at line 1:
ORA-01918: user
'IX'
does not exist
DROP USER sh CASCADE
*
ERROR at line 1:
ORA-01918: user
'SH'
does not exist
DROP USER bi CASCADE
*
ERROR at line 1:
ORA-01918: user
'BI'
does not exist
Connected.
SP2-0310: unable to
open
file
"__SUB__CWD__/human_resources/hr_main.sql"
Connected.
SP2-0310: unable to
open
file
"__SUB__CWD__/order_entry/oe_main.sql"
Connected.
SP2-0310: unable to
open
file
"__SUB__CWD__/product_media/pm_main.sql"
Connected.
SP2-0310: unable to
open
file
"__SUB__CWD__/info_exchange/ix_main.sql"
Connected.
SP2-0310: unable to
open
file
"__SUB__CWD__/sales_history/sh_main.sql"
Connected.
SP2-0310: unable to
open
file
"__SUB__CWD__/bus_intelligence/bi_main.sql"
Connected.
not spooling currently
SP2-0310: unable to
open
file
"__SUB__CWD__/mkverify.sql"
从上面看到输出报错,没有安装成功。报错的是“__SUB__CWD__”没有找到,打开 mksample.sql 文件,确实有这个变量,但不知道在哪里声明的。
重新查看 README.md 文档看到需要把“__SUB__CWD__”这个变量替换为当前路径,还给出了命令:
[oracle
@rhel7
db-sample-schemas-12.2.0.1]$ perl -p -i.bak -e
's#__SUB__CWD__#'
$(pwd)
'#g'
*.sql */*.sql */*.dat
执行完上面的脚本后重新安装示例 Schema:
sys@ORA12C>@mksample 123456 123456 hr oe pm ix sh bi users
temp
/home/oracle/dbca/ 192.168.56.22:1521/ora12c
最终安装成功:
system@ORA12C>
select
username,created
from
dba_users
where
created>sysdate-1;
USERNAME CREATED
------------------------------ -----------------
OE 20170816 23:32:22
SH 20170816 23:34:25
PM 20170816 23:33:13
IX 20170816 23:34:12
BI 20170816 23:36:20
HR 20170816 23:32:07
参考:http://docs.oracle.com/database/122/COMSC/installing-sample-schemas.htm#COMSC-GUID-B0BEE222-D8B0-4B68-B359-DEA153956EF6
更多 Oracle 相关信息见 Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12
本文永久更新链接地址 :http://www.linuxidc.com/Linux/2017-08/146337.htm