赞
踩
在做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 athttps://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 thedbcaoption. 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
specifypasswordforSYSTEMasparameter1:
Entervaluefor1:123456
specifypasswordforSYSasparameter2:
Entervaluefor2:123456
specifypasswordforHRasparameter3:
Entervaluefor3:hr
specifypasswordforOEasparameter4:
Entervaluefor4:oe
specifypasswordforPMasparameter5:
Entervaluefor5:pm
specifypasswordforIXasparameter6:
Entervaluefor6:ix
specifypasswordforSHasparameter7:
Entervaluefor7:sh
specifypasswordforBIasparameter8:
Entervaluefor8:bi
specifydefaulttablespaceasparameter9:
Entervaluefor9:users
specifytemporarytablespaceasparameter10:
Entervaluefor10:temp
specifylogfiledirectory(includingtrailingdelimiter)asparameter11:
Entervaluefor11:/home/oracle/dbca
specifyconnectstringasparameter12:
Entervaluefor12:localhost:1521/ora12c
SampleSchemasarebeingcreated...
mkdir:cannotcreatedirectory‘/home/oracle/dbca’:Fileexists
Connected.
DROPUSERhrCASCADE
*
ERRORatline1:
ORA-01918:user'HR'doesnotexist
DROPUSERoeCASCADE
*
ERRORatline1:
ORA-01918:user'OE'doesnotexist
DROPUSERpmCASCADE
*
ERRORatline1:
ORA-01918:user'PM'doesnotexist
DROPUSERixCASCADE
*
ERRORatline1:
ORA-01918:user'IX'doesnotexist
DROPUSERshCASCADE
*
ERRORatline1:
ORA-01918:user'SH'doesnotexist
DROPUSERbiCASCADE
*
ERRORatline1:
ORA-01918:user'BI'doesnotexist
Connected.
SP2-0310:unabletoopenfile"__SUB__CWD__/human_resources/hr_main.sql"
Connected.
SP2-0310:unabletoopenfile"__SUB__CWD__/order_entry/oe_main.sql"
Connected.
SP2-0310:unabletoopenfile"__SUB__CWD__/product_media/pm_main.sql"
Connected.
SP2-0310:unabletoopenfile"__SUB__CWD__/info_exchange/ix_main.sql"
Connected.
SP2-0310:unabletoopenfile"__SUB__CWD__/sales_history/sh_main.sql"
Connected.
SP2-0310:unabletoopenfile"__SUB__CWD__/bus_intelligence/bi_main.sql"
Connected.
notspoolingcurrently
SP2-0310:unabletoopenfile"__SUB__CWD__/mkverify.sql"
从上面看到输出报错,没有安装成功。报错的是“__SUB__CWD__”没有找到,打开mksample.sql文件,确实有这个变量,但不知道在哪里声明的。
重新查看README.md文档看到需要把“__SUB__CWD__”这个变量替换为当前路径,还给出了命令:
[oracle@rhel7db-sample-schemas-12.2.0.1]$perl-p-i.bak-e's#__SUB__CWD__#'$(pwd)'#g'*.sql*/*.sql*/*.dat
执行完上面的脚本后重新安装示例Schema:
sys@ORA12C>@mksample123456123456hroepmixshbiuserstemp/home/oracle/dbca/192.168.56.22:1521/ora12c
最终安装成功:
system@ORA12C>selectusername,createdfromdba_userswherecreated>sysdate-1;
USERNAMECREATED
-----------------------------------------------
OE2017081623:32:22
SH2017081623:34:25
PM2017081623:33:13
IX2017081623:34:12
BI2017081623:36:20
HR2017081623:32:07
总结
如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。