本文主要是介绍Oracle 数据库12c安装示例db-sample-schemas(pdb下安装),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
参考官方文档: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
从上面的官方文档中我们可以看到从Oracle12.2版本开始,示例Schemas的脚本被放到了GitHub上,在DBCA安装时只会安装hr示例Schema。
oracle 12c在结构上做出了调整,引入了CDB和PDB的概念。官方文档没有强调必需要在PDB下安装示例。
用sys默认登录的是CDB
在oracle用户下,我pdb的名称是proc。sys system用户的密码都设置为oracle
[oracle@orcl ~]$ sqlplus / as sysdbaSQL*Plus: Release 12.2.0.1.0 Production on Tue Dec 3 15:16:35 2019Copyright (c) 1982, 2016, Oracle. All rights reserved.Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit ProductionSQL> show pdbsCON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------2 PDB$SEED READ ONLY NO3 PROC READ WRITE NO
查看下端口状态
使用system用户验证下登录
sqlplus system/oracle@127.0.0.1:1521/proc
如果登录不了,可能是pdb还没打开
SQL> alter session set container=proc;会话已更改。SQL> alter database open;
在oracle用户下载示例,假设你已经安装git软件,文件约30MB左右,如果下载太慢,可以pc下载后再上传
cd $HOME
git 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 db-sample-schemas/
$ ls
bus_intelligence drop_sch.sql.bak LICENSE.md mkplug.sql mksample.sql.bak mkverify.sql product_media sales_history
CONTRIBUTING.md human_resources mk_dir.sql mkplug.sql.bak mkunplug.sql mkverify.sql.bak README.md shipping
drop_sch.sql info_exchange mk_dir.sql.bak mksample.sql mkunplug.sql.bak order_entry README.txt
修改:
cd $HOME/db-sample-schemas
perl -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用户和表,不要在生产数据库上做这样的操作。
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/procSQL*Plus: Release 12.2.0.1.0 Production on Tue Dec 3 16:00:04 2019Copyright (c) 1982, 2016, Oracle. All rights reserved.Last Successful login time: Tue Dec 03 2019 15:59:29 +08:00Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> select * from regions;REGION_ID REGION_NAME
---------- -------------------------1 Europe2 Americas3 Asia4 Middle East and Africa
这篇关于Oracle 数据库12c安装示例db-sample-schemas(pdb下安装)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!