在Oracle和MySQL上安装hr schema、example和Scott schema

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群版 2核4GB 100GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介: 19c examples 安装完成,在$ORACLE_HOME/demo/schema/human_resources 目录下执行hr_main.sql 文件创建 hr用户

在oracle上安装hr schema

19c examples 安装完成,在$ORACLE_HOME/demo/schema/human_resources 目录下执行hr_main.sql 文件创建 hr用户:


SYS@orcl(CDB$ROOT)> alter session set container=pdb1;
Session altered.
SYS@orcl(CDB$ROOT)> create tablespace users datafile '/u01/app/oracle/oradata/ORCL/pdb1/user01.dbf' size 100m autoextend on;
Tablespace created.
SYSTEM@oracleace/pdb1.yaoyuan.com(PDB1)> @?/demo/schema/human_resources/hr_main.sql
specify password for HR as parameter 1:
Enter value for 1: hr
specify default tablespeace for HR as parameter 2:
Enter value for 2: users
specify temporary tablespace for HR as parameter 3:
Enter value for 3: temp
specify log path as parameter 4:
Enter value for 4: /tmp

安装完成后进行检查:


$ sqlplus hr/hr@pdb1
...
SQL> select table_name from user_tables;
TABLE_NAME
--------------------------------------------------------------------------------
COUNTRIES
REGIONS
LOCATIONS
DEPARTMENTS
JOBS
EMPLOYEES
JOB_HISTORY
7 rows selected.
SQL> select count(*) from employees;
  COUNT(*)
----------
       107



在MySQL上安装hr schema

在MySQL上也可以安装和Oracle同样的hr schema,参见:https://github.com/nomemory/hr-schema-mysql。 安装方法如下:

wget https://github.com/nomemory/hr-schema-mysql/archive/refs/heads/master.zip
 unzip master.zip 
 [oracle@dell hr-schema-mysql-master]$ ll
total 36
-rw-r--r--. 1 oracle oinstall 31342 Feb 15  2021 hr-schema-mysql.sql
-rw-r--r--. 1 oracle oinstall   231 Feb 15  2021
[oracle@dell hr-schema-mysql-master]$ mysql < hr-schema-mysql.sql


安装完成后检查:

mysql> use hr;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+------------------+
| Tables_in_hr     |
+------------------+
| countries        |
| departments      |
| emp_details_view |
| employees        |
| job_history      |
| jobs             |
| locations        |
| regions          |
+------------------+
8 rows in set (0.00 sec)
mysql> select count(*) from employees;
+----------+
| count(*) |
+----------+
|      107 |
+----------+
1 row in set (0.01 sec)



安装examples

在Oracle官方文档中有一个安装文档《Database Examples Installation Guide》,这个文档只有一章!


官网下载 LINUX.X64_193000_examples.zip 压缩包,并上传服务器,解压目录结构如下


$ cd /home/oracle/examples/
[oracle@wl examples]$ ls
install response runInstaller stage welcome.html

运行runInstaller进行图像界面的安装


字符静默安装

$ /directory_path/runInstaller [-silent] -responseFile responsefilename
[oracle@oracleace examples]$ pwd
/media/sf_oracle/19c/examples
[oracle@oracleace examples]$ ./runInstaller -silent -force -ignorePrereq -ignoreSysPrereqs -responseFile /media/sf_oracle/19c/examples/response/demos_install.rsp 
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 415 MB.   Actual 28381 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 7935 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2022-03-28_06-45-48PM. Please wait ...[oracle@oracleace examples]$ 
[oracle@oracleace examples]$ The response file for this session can be found at:
 /u01/app/oracle/product/19.3.0/db_1/install/response/examples_2022-03-28_06-45-48PM.rsp
You can find the log of this install session at:
 /u01/app/oraInventory/logs/installActions2022-03-28_06-45-48PM.log
Successfully Setup Software.
The installation of Oracle Database 19c Examples was successful.
Please check '/u01/app/oraInventory/logs/silentInstall2022-03-28_06-45-48PM.log' for more details.




安装时并不直接修改数据库,而是安装脚本。


安装 HR、OE、PM、IX、SH、BI 用户

从 12.2 开始,Oracle 自带的 examples 只是包含了 HR 这个 schema,其他schema,需要自行从 github 下载和安装,19c 地址:

https://github.com/oracle/db-sample-schemas/releases/tag/v19c


参考文档: https://docs.oracle.com/en/database/oracle/oracle-database/19/comsc/toc.htm


解压缩

unzip db-sample-schemas-19c.zip

查看其中的readme.txt和readme.md文档

移动到对应的目录


[oracle@oracleace ~]$ cp -r /media/sf_oracle/19c/db-sample-schemas-19c $ORACLE_HOME/demo/schema
mv db-sample-schemas-19c  $ORACLE_HOME/demo/schema/



把脚本中的_SUB__CWD__替换为当前路径:


[oracle@wl db-sample-schemas-19c] pwd
/u01/app/oracle/product/19.3.0/db_1/demo/schema/db-sample-schemas-19c
[oracle@wl db-sample-schemas-19c]$ perl -p -i.bak -e 's#__SUB__CWD__#'$(pwd)'#g' *.sql */*.sql */*.dat



根据readme.md文档中的提示安装方法进行安装


sqlplus system/systempw@connect_string
@mksample systempw syspw hrpw oepw pmpw ixpw shpw bipw users temp /your/path/to/log/ connect_string
[oracle@oracleace db-sample-schemas-19c]$ sqlplus system/oracle@oracleace/pdb1.yaoyuan.com
...
SYSTEM@oracleace/pdb1.yaoyuan.com(PDB1)> @?/demo/schema/db-sample-schemas-19c/mksample  oracle oracle hr oe pm ix sh bi users temp $ORACLE_HOME/demo/schema/log/ oracleace:1521/pdb1.yaoyuan.com



安装 scott schema

修改utlsampl.sql文件,把 CONNECT SCOTT/tiger 改为

CONNECT SCOTT/tiger@localhost/pdb1.yaoyuan.com
[oracle@oracleace ~]$ sqlplus system/oracle@localhost/pdb1.yaoyuan.com
SCOTT@localhost/pdb1.yaoyuan.com(PDB1)> @/u01/app/oracle/product/19.3.0/db_1/rdbms/admin/utlsampl.sql
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0



查询安装好的表:

SCOTT@localhost/pdb1.yaoyuan.com(PDB1)> select table_name from user_tables;
TABLE_NAME
--------------------------------------------------------------------------------
DEPT
EMP
BONUS
SALGRADE
相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
11天前
|
SQL Oracle 关系型数据库
MySQL、SQL Server和Oracle数据库安装部署教程
数据库的安装部署教程因不同的数据库管理系统(DBMS)而异,以下将以MySQL、SQL Server和Oracle为例,分别概述其安装部署的基本步骤。请注意,由于软件版本和操作系统的不同,具体步骤可能会有所变化。
45 3
|
26天前
|
SQL Oracle 关系型数据库
Oracle数据库基础教程:从安装到基本操作的全面介绍
Oracle数据库基础教程:从安装到基本操作的全面介绍
|
26天前
|
SQL Oracle 关系型数据库
Oracle数据库基础教程:从安装到基本操作的全面介绍
Oracle数据库基础教程:从安装到基本操作的全面介绍
|
1月前
|
Oracle 数据可视化 关系型数据库
Oracle数据库安装及使用Navicat连接oracle2
Oracle数据库安装及使用Navicat连接oracle
34 1
|
1月前
|
Oracle 安全 关系型数据库
Oracle数据库安装及使用Navicat连接oracle1
Oracle数据库安装及使用Navicat连接oracle
36 0
|
1月前
|
Oracle 关系型数据库 数据库
Oracle 11G数据库安装步骤及截图操作2
Oracle 11G数据库安装步骤及截图操作
27 0
|
1月前
|
Oracle 安全 关系型数据库
Oracle 11G数据库安装步骤及截图操作1
Oracle 11G数据库安装步骤及截图操作
60 0
|
1月前
|
SQL Oracle 关系型数据库
Oracle SQLcl 安装和使用
Oracle SQLcl 安装和使用
43 0
|
Oracle 关系型数据库 索引
Oracle Star Schema简析
数据仓库这么多年来发展的成果,我认为恐怕最重要的要算star schema了,可以说它是整个数据仓库的基石。
1015 0
|
2天前
|
Oracle 安全 关系型数据库

推荐镜像

更多