Oracle 12.2安装示例schema

前端之家收集整理的这篇文章主要介绍了Oracle 12.2安装示例schema前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

在做Oracle数据库实验时都会用到一些示例SCHEMA如:HR、OE、SH等,在Oracle11g版本时在DBCA时直接勾选Sample Schemas就可以安装这些示例SCHEMA,如下图:

wKioL1mUaMaBJvtbAAEnBYK5ZxI858.png

但到了Oracle12.2 版本,也有一个示例Schemas选项卡如下图所示:

wKioL1mUaQ6Ttns9AAC5h-qydjM478.png

但是数据库安装完成后却还是没有这些示例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安装脚本:

wKioL1mUalCh5__3AABZYHHGMr4457.png

从README.txt文档中找到安装方法,开始安装:

  1. sys@ORA12C>@mksample
  2.  
  3. specifypasswordforSYSTEMasparameter1:
  4. Entervaluefor1:123456
  5.  
  6. specifypasswordforSYSasparameter2:
  7. Entervaluefor2:123456
  8.  
  9. specifypasswordforHRasparameter3:
  10. Entervaluefor3:hr
  11.  
  12. specifypasswordforOEasparameter4:
  13. Entervaluefor4:oe
  14.  
  15. specifypasswordforPMasparameter5:
  16. Entervaluefor5:pm
  17.  
  18. specifypasswordforIXasparameter6:
  19. Entervaluefor6:ix
  20.  
  21. specifypasswordforSHasparameter7:
  22. Entervaluefor7:sh
  23.  
  24. specifypasswordforBIasparameter8:
  25. Entervaluefor8:bi
  26.  
  27. specifydefaulttablespaceasparameter9:
  28. Entervaluefor9:users
  29.  
  30. specifytemporarytablespaceasparameter10:
  31. Entervaluefor10:temp
  32.  
  33. specifylogfiledirectory(includingtrailingdelimiter)asparameter11:
  34. Entervaluefor11:/home/oracle/dbca
  35.  
  36. specifyconnectstringasparameter12:
  37. Entervaluefor12:localhost:1521/ora12c
  38.  
  39. SampleSchemasarebeingcreated...
  40.  
  41. mkdir:cannotcreatedirectory‘/home/oracle/dbca’:Fileexists
  42.  
  43. Connected.
  44. DROPUSERhrCASCADE
  45. *
  46. ERRORatline1:
  47. ORA-01918:user'HR'doesnotexist
  48.  
  49.  
  50. DROPUSERoeCASCADE
  51. *
  52. ERRORatline1:
  53. ORA-01918:user'OE'doesnotexist
  54.  
  55.  
  56. DROPUSERpmCASCADE
  57. *
  58. ERRORatline1:
  59. ORA-01918:user'PM'doesnotexist
  60.  
  61.  
  62. DROPUSERixCASCADE
  63. *
  64. ERRORatline1:
  65. ORA-01918:user'IX'doesnotexist
  66.  
  67.  
  68. DROPUSERshCASCADE
  69. *
  70. ERRORatline1:
  71. ORA-01918:user'SH'doesnotexist
  72.  
  73.  
  74. DROPUSERbiCASCADE
  75. *
  76. ERRORatline1:
  77. ORA-01918:user'BI'doesnotexist
  78.  
  79.  
  80. Connected.
  81. SP2-0310:unabletoopenfile"__SUB__CWD__/human_resources/hr_main.sql"
  82. Connected.
  83. SP2-0310:unabletoopenfile"__SUB__CWD__/order_entry/oe_main.sql"
  84. Connected.
  85. SP2-0310:unabletoopenfile"__SUB__CWD__/product_media/pm_main.sql"
  86. Connected.
  87. SP2-0310:unabletoopenfile"__SUB__CWD__/info_exchange/ix_main.sql"
  88. Connected.
  89. SP2-0310:unabletoopenfile"__SUB__CWD__/sales_history/sh_main.sql"
  90. Connected.
  91. SP2-0310:unabletoopenfile"__SUB__CWD__/bus_intelligence/bi_main.sql"
  92. Connected.
  93. notspoolingcurrently
  94. SP2-0310:unabletoopenfile"__SUB__CWD__/mkverify.sql"

从上面看到输出报错,没有安装成功。报错的是“__SUB__CWD__”没有找到,打开mksample.sql文件,确实有这个变量,但不知道在哪里声明的。

重新查看README.md文档看到需要把“__SUB__CWD__”这个变量替换为当前路径,还给出了命令:

  1. [oracle@rhel7db-sample-schemas-12.2.0.1]$perl-p-i.bak-e's#__SUB__CWD__#'$(pwd)'#g'*.sql*/*.sql*/*.dat

执行完上面的脚本后重新安装示例Schema:

  1. sys@ORA12C>@mksample123456123456hroepmixshbiuserstemp/home/oracle/dbca/192.168.56.22:1521/ora12c

最终安装成功:

  1. system@ORA12C>selectusername,createdfromdba_userswherecreated>sysdate-1;
  2.  
  3. USERNAMECREATED
  4. -----------------------------------------------
  5. OE2017081623:32:22
  6. SH2017081623:34:25
  7. PM2017081623:33:13
  8. IX2017081623:34:12
  9. BI2017081623:36:20
  10. HR2017081623:32:07

参考:http://docs.oracle.com/database/122/COMSC/installing-sample-schemas.htm#COMSC-GUID-B0BEE222-D8B0-4B68-B359-DEA153956EF6

猜你在找的Oracle相关文章