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

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,高可用系列 2核4GB
简介: 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
相关实践学习
如何快速连接云数据库RDS MySQL
本场景介绍如何通过阿里云数据管理服务DMS快速连接云数据库RDS MySQL,然后进行数据表的CRUD操作。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
1月前
|
SQL Oracle 关系型数据库
MySQL 和 Oracle 的区别?
本文对比了Oracle和MySQL数据库的多个方面。Oracle适用于大型数据库,支持高并发和大访问量,市场占有率为40%,安装占用空间较大,约3G;而MySQL适合中小型应用,是开源免费的,安装仅需152M。两者在主键生成、字符串处理、SQL语句、事务处理等方面存在差异。Oracle功能更为强大,尤其在企业级应用中表现突出,而MySQL则以简单易用见长。
MySQL 和 Oracle 的区别?
|
1月前
|
关系型数据库 MySQL 数据库
Docker Compose V2 安装常用数据库MySQL+Mongo
以上内容涵盖了使用 Docker Compose 安装和管理 MySQL 和 MongoDB 的详细步骤,希望对您有所帮助。
180 42
|
8天前
|
Oracle 关系型数据库 MySQL
使用崖山YMP 迁移 Oracle/MySQL 至YashanDB 23.2 验证测试
这篇文章是作者尚雷关于使用崖山YMP迁移Oracle/MySQL至YashanDB 23.2的验证测试分享。介绍了YMP的产品信息,包括架构、版本支持等,还详细阐述了外置库部署、YMP部署、访问YMP、数据源管理、任务管理(创建任务、迁移配置、离线迁移、校验初始化、一致性校验)及MySQL迁移的全过程。
|
2月前
|
监控 Oracle 关系型数据库
Mysql、Oracle审计日志的开启
通过上述步骤,可以在 MySQL 和 Oracle 数据库中启用和配置审计日志。这些日志对于监控数据库操作、提高安全性和满足合规性要求非常重要。确保正确配置审计参数和策略,定期查看和分析审计日志,有助于及时发现并处理潜在的安全问题。
100 11
|
2月前
|
Oracle 关系型数据库 Linux
linux8安装oracle 11g遇到的问题记录
Oracle 11g在Linux 8上安装时会遇到link编译环节的问题。官方建议忽略安装中的链接错误,安装完成后应用DBPSU 11.2.0.4.240716补丁及一次性补丁33991024,再重新编译二进制文件,并配置监听器和数据库。但因11g已退出服务期,这些补丁需付费获取。网上信息显示22年1月的PSU补丁也可解决问题,找到该补丁后按常规方式打补丁即可。如有需求或疑问可咨询我。
106 20
|
2月前
|
安全 关系型数据库 MySQL
CentOS7仅安装部署MySQL80客户端
通过上述步骤,你可以在CentOS 7上成功安装并配置MySQL 8.0客户端。这个过程确保你能够使用MySQL客户端工具连接和管理远程的MySQL数据库,而不需要在本地安装MySQL服务器。定期更新MySQL客户端可以确保你使用的是最新的功能和安全修复。
290 16
|
3月前
|
关系型数据库 MySQL 数据库
【MySQL基础篇】MySQL概述、Windows下载MySQL8.0超详细图文安装教程
在这一章节,主要介绍两个部分,数据库相关概念及MySQL数据库的介绍、下载、安装、启动及连接。接着,详细描述了MySQL 8.0的版本选择与下载,推荐使用社区版(免费)。安装过程包括自定义安装路径、配置环境变量、启动和停止服务、以及客户端连接测试。此外,还提供了在同一台电脑上安装多个MySQL版本的方法及卸载步骤。最后,解释了关系型数据库(RDBMS)的特点,即基于二维表存储数据,使用SQL语言进行操作,格式统一且便于维护。通过具体的结构图展示了MySQL的数据模型,说明了数据库服务器、数据库、表和记录之间的层次关系。
【MySQL基础篇】MySQL概述、Windows下载MySQL8.0超详细图文安装教程
|
3月前
|
NoSQL 关系型数据库 Redis
《docker高级篇(大厂进阶):1.Docker复杂安装详说》包括:安装mysql主从复制、安装redis集群
《docker高级篇(大厂进阶):1.Docker复杂安装详说》包括:安装mysql主从复制、安装redis集群
146 14
|
3月前
|
关系型数据库 MySQL 数据库
docker高级篇(大厂进阶):安装mysql主从复制
docker高级篇(大厂进阶):安装mysql主从复制
137 24
|
2月前
|
关系型数据库 MySQL 应用服务中间件
《docker基础篇:8.Docker常规安装简介》包括:docker常规安装总体步骤、安装tomcat、安装mysql、安装redis
《docker基础篇:8.Docker常规安装简介》包括:docker常规安装总体步骤、安装tomcat、安装mysql、安装redis
159 7

热门文章

最新文章

推荐镜像

更多