Oracle 23AI创建示例库

一、示例库介绍

多年来,Oracle 一直使用简单的数据库模式 SCOTT 及其两个突出的表 EMP 和 DEPT,用于文档和培训中的各种示例。但不少小伙伴并不知道如何创建这些示例数据,其实Oracle官方上就有提供对应的方法,本文就带领大家完成示例库的创建。

1.1 关于示例架构

示例数据库模式为 Oracle 数据库的每个版本中的示例提供了一个通用平台。示例架构是一组相互链接的数据库架构。这套方法提供了解决复杂性的方法:

  • 架构人力资源 (HR) 对于介绍基本主题很有用。此架构的扩展支持 Oracle Internet Directory 演示。
  • 模式顺序输入 (OE) 对于处理中等复杂度的问题很有用。此架构中提供了许多数据类型,包括非标量数据类型。
  • 架构产品介质 (PM) 专用于打印介质数据类型。
  • Schema Sales History (SH) 旨在允许使用大量数据进行演示。此架构的扩展提供了对高级分析处理的支持。

1.2 示例架构概述

Oracle 数据库示例架构基于通过各种渠道销售商品的虚构示例公司。该公司在全球范围内开展业务,以完成产品订单。它有多个部门,每个部门都由一个示例数据库架构表示。

主题:

  • Schema HR -- Division Human Resources 跟踪有关公司员工和设施的信息。
  • Schema OE -- Division Order Entry 通过各种渠道跟踪产品库存和公司产品的销售情况。
  • Schema PM -- Division Product Media 维护有关公司销售的每种产品的描述和详细信息。
  • 架构 IX -- Division Information Exchange 通过 B2B 应用程序管理运输。
  • Schema SH -- Division Sales 跟踪业务统计数据以促进业务决策。
  • Schema CO - Division Customer Orders 对由客户、产品、商店和订单数据组成的简单零售应用程序进行建模。

二 安装示例架构

很多使用Oracle的小伙伴在安装完数据库之后,发现没有这些示例用户,导致一些实验无法进行。接下来,我们将一步步带领大家导入这些示例用户的数据。

2.1 安装示例架构

可以使用单个脚本一起安装示例架构。 19c的示例库安装需要调用go语言,存在一些BUG,以下的方式更为简洁方便。

安装示例架构的过程如下所示:

  1. 若要查找示例架构安装脚本的最新版本,请转到以下 GitHub 位置:

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

例如,如果需要23.4版本的脚本,请转到以下位置:

https://github.com/oracle-samples/db-sample-schemas/releases/tag/v23.3

  1. 克隆 GitHub 存储库,或从 GitHub 下载 ZIP 包并提取文件。

下载文件名

db-sample-schemas-23.3.tar.gz

  1. 脚本上传服务器,并解压

cd /home/oracle

tar -zxvf db-sample-schemas-23.3.tar.gz

  1. 从 SQL*Plus 命令行界面使用以下语法:

To install the "HR" schema, complete the following steps:

  1. "cd" into the "human_resources" folder.

  2. Connect to the target database with a privileged user via SQLcl or SQL*Plus.

  3. Run the "hr_install.sql" script and provide inputs for the prompts.

cd human_resources

sql <system>@<connect_string>

@hr_install.sql

安装hr示例库测试示例如下

--进入安装主目录

cd /home/oracle/db-sample-schemas-23.3

--查看示例库

ll

total 28

drwxr-xr-x. 2 oracle oinstall 131 Mar 29 2024 customer_orders

drwxr-xr-x. 2 oracle oinstall 172 Nov 7 17:11 human_resources

-rw-r--r--. 1 oracle oinstall 1094 Mar 29 2024 LICENSE.txt

drwxr-xr-x. 3 oracle oinstall 4096 Mar 29 2024 order_entry

drwxr-xr-x. 2 oracle oinstall 4096 Mar 29 2024 product_media

-rw-r--r--. 1 oracle oinstall 3784 Mar 29 2024 README.md

-rw-r--r--. 1 oracle oinstall 3613 Mar 29 2024 README.txt

drwxr-xr-x. 2 oracle oinstall 4096 Nov 7 17:13 sales_history

-rw-r--r--. 1 oracle oinstall 1737 Mar 29 2024 SECURITY.md

--进入hr示例库

cd human_resources

--登录pdb1,执行脚本

sqlplus sys/oracle@db1:1521/freepdb1 as sysdba

@hr_install.sql

--输入密码

Thank you for installing the Oracle Human Resources Sample Schema.

This installation script will automatically exit your database session

at the end of the installation or if any error is encountered.

The entire installation will be logged into the 'hr_install.log' log file.

Enter a password for the user HR: -->指定HR密码

Enter a tablespace for HR [USERS]: -->默认即可

Do you want to overwrite the schema, if it already exists? [YES|no]: -->默认YES

检查示例库

col table_name for a30

col owner for a30

set pages 1000

select owner,table_name from dba_tables where owner in ('HR','SH');

select owner,table_name from dba_tables where owner='HR';

OWNER TABLE_NAME


HR COUNTRIES

HR REGIONS

HR LOCATIONS

HR DEPARTMENTS

HR JOBS

HR EMPLOYEES

HR JOB_HISTORY

SQL>

其它示例库同上方式创建。

这里需要重点说明下,不明白的看README.txt和README.md

相关推荐
雷工笔记16 分钟前
MES 系统 设备保养管理模块详细设计方案
运维·数据库
晚风_END2 小时前
Linux|操作系统|zfs文件系统的使用详解
linux·运维·服务器·数据库·postgresql·性能优化·宽度优先
晚风_END8 小时前
Linux|操作系统|最新版openzfs编译记录
linux·运维·服务器·数据库·spring·中间件·个人开发
dLYG DUMS9 小时前
DBeaver连接本地MySQL、创建数据库表的基础操作
数据库·mysql
苍煜9 小时前
MySQL分库分表和ES到底怎么选?
数据库·mysql·elasticsearch
茉莉玫瑰花茶10 小时前
Qt 信号与槽 [ 1 ]
开发语言·数据库·qt
czlczl2002092510 小时前
松散索引扫描/跳跃索引扫描
数据库·mysql·性能优化
星马梦缘12 小时前
数据库作战记录 实验7、8
数据库·sql·oracle
安逸sgr12 小时前
Hermes Agent + Obsidian 打造第二大脑(六):分层记忆系统的设计逻辑——L0/L1/L2/L3 四层记忆详解
数据库·agent·知识库·hermes·hermesagent
苍煜12 小时前
一篇讲懂分库分表:概念、spirngboot实战
数据库·oracle