参考官方文档:https://docs.oracle.com/en/database/oracle/oracle-database/12.2/comsc/installing-sample-schemas.html#GUID-4D4984DD-A5F7-4080-A6F8-6306DA88E9FC
github下载地址:https://github.com/oracle/db-sample-schemas
![1cd79ae32029e0163ee7f3d5ad0196c7.png](https://img-blog.csdnimg.cn/img_convert/1cd79ae32029e0163ee7f3d5ad0196c7.png)
从上面的官方文档中我们可以看到从Oracle12.2版本开始,示例Schemas的脚本被放到了GitHub上,在DBCA安装时只会安装hr示例Schema。
oracle 12c在结构上做出了调整,引入了CDB和PDB的概念。官方文档没有强调必需要在PDB下安装示例。
用sys默认登录的是CDB
在oracle用户下,我pdb的名称是proc。sys system用户的密码都设置为oracle
[oracle@orcl ~]$ sqlplus / as sysdba SQL*Plus: Release 12.2.0.1.0 Production on Tue Dec 3 15:16:35 2019 Copyright (c) 1982, 2016, Oracle. All rights reserved. Connected to:Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PROC READ WRITE NO
查看下端口状态
![c14e2b5b7da23975cb72af81cb06b3c0.png](https://img-blog.csdnimg.cn/img_convert/c14e2b5b7da23975cb72af81cb06b3c0.png)
`使用system用户验证下登录
sqlplus system/oracle@127.0.0.1:1521/proc
![45001582a652b9933d16e3fd521330b7.png](https://img-blog.csdnimg.cn/img_convert/45001582a652b9933d16e3fd521330b7.png)
在oracle用户下载示例,假设你已经安装git软件,文件约30MB左右,如果下载太慢,可以pc下载后再上传
cd $HOMEgit clone https://github.com/oracle/db-sample-schemas.git#git clone -b v12.2.0.1 https://github.com/oracle/db-sample-schemas.git
修改:
cd $HOME/db-sample-schemasperl -p -i.bak -e 's#__SUB__CWD__#'$(pwd)'#g' *.sql */*.sql */*.dat source /usr/local/bin/oraenv
一次性安装所有示例Schema
The mksample script expects 11 parameters. Provide the password for SYSTEM and SYS, and for schemas HR, OE, PM, IX, and SH. Specify a temporary and a default tablespace, and make sure to end the name of the log file directory with a trailing slash.
mksample脚本会重置HR, OE, PM, IX, and SH用户和表,不要在生产数据库上做这样的操作。
![953d2c71afb68e9076b19f7e6967f7da.png](https://img-blog.csdnimg.cn/img_convert/953d2c71afb68e9076b19f7e6967f7da.png)
installation script 示例
sqlplus system/systempw@connect_string@mksample systempw syspw hrpw oepw pmpw ixpw shpw bipw users temp /your/path/to/log/ connect_string
根据你实际的设置来修改:
sqlplus system/oracle@localhost:1521/proc@mksample oracle oracle hrpw oepw pmpw ixpw shpw bipw users temp $ORACLE_HOME//demo/schema/log/ localhost:1521/proc
大概要几分钟安装完成。
验证:
$ sqlplus hr/hrpw@127.0.0.1:1521/proc SQL*Plus: Release 12.2.0.1.0 Production on Tue Dec 3 16:00:04 2019 Copyright (c) 1982, 2016, Oracle. All rights reserved. Last Successful login time: Tue Dec 03 2019 15:59:29 +08:00 Connected to:Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit ProductionSQL> select * from regions; REGION_ID REGION_NAME---------- ------------------------- 1 Europe 2 Americas 3 Asia 4 Middle East and Africa