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

本文涉及的产品
RDS MySQL DuckDB 分析主实例,集群系列 4核8GB
RDS MySQL DuckDB 分析主实例,基础系列 4核8GB
RDS AI 助手,专业版
简介: 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
相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。 &nbsp; 相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情:&nbsp;https://www.aliyun.com/product/rds/mysql&nbsp;
相关文章
|
10月前
|
Oracle 关系型数据库 MySQL
Oracle linux 8 二进制安装 MySQL 8.4企业版
Oracle linux 8 二进制安装 MySQL 8.4企业版
443 1
|
12月前
|
SQL Oracle 关系型数据库
MySQL 和 Oracle 的区别?
本文对比了Oracle和MySQL数据库的多个方面。Oracle适用于大型数据库,支持高并发和大访问量,市场占有率为40%,安装占用空间较大,约3G;而MySQL适合中小型应用,是开源免费的,安装仅需152M。两者在主键生成、字符串处理、SQL语句、事务处理等方面存在差异。Oracle功能更为强大,尤其在企业级应用中表现突出,而MySQL则以简单易用见长。
1373 7
MySQL 和 Oracle 的区别?
|
11月前
|
Oracle 关系型数据库 MySQL
使用崖山YMP 迁移 Oracle/MySQL 至YashanDB 23.2 验证测试
这篇文章是作者尚雷关于使用崖山YMP迁移Oracle/MySQL至YashanDB 23.2的验证测试分享。介绍了YMP的产品信息,包括架构、版本支持等,还详细阐述了外置库部署、YMP部署、访问YMP、数据源管理、任务管理(创建任务、迁移配置、离线迁移、校验初始化、一致性校验)及MySQL迁移的全过程。
|
监控 Oracle 关系型数据库
Mysql、Oracle审计日志的开启
通过上述步骤,可以在 MySQL 和 Oracle 数据库中启用和配置审计日志。这些日志对于监控数据库操作、提高安全性和满足合规性要求非常重要。确保正确配置审计参数和策略,定期查看和分析审计日志,有助于及时发现并处理潜在的安全问题。
768 11
|
Oracle 关系型数据库 Linux
linux8安装oracle 11g遇到的问题记录
Oracle 11g在Linux 8上安装时会遇到link编译环节的问题。官方建议忽略安装中的链接错误,安装完成后应用DBPSU 11.2.0.4.240716补丁及一次性补丁33991024,再重新编译二进制文件,并配置监听器和数据库。但因11g已退出服务期,这些补丁需付费获取。网上信息显示22年1月的PSU补丁也可解决问题,找到该补丁后按常规方式打补丁即可。如有需求或疑问可咨询我。
606 20
|
Oracle 关系型数据库 数据库
|
SQL Oracle 关系型数据库
|
Oracle 关系型数据库 网络安全

推荐镜像

更多