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

相关推荐
老华带你飞12 分钟前
商城推荐系统|基于SprinBoot+vue的商城推荐系统(源码+数据库+文档)
java·前端·数据库·vue.js·spring boot·毕设·商城推荐系统
一 乐16 分钟前
物业管理系统|小区物业管理|基于SprinBoot+vue的小区物业管理系统(源码+数据库+文档)
java·前端·数据库·vue.js·spring boot·后端
这周也會开心32 分钟前
Spring框架
java·数据库·spring
gys98951 小时前
uniapp使用sqlite模块
数据库·sqlite·uni-app
凌冰_2 小时前
Java Maven+lombok+MySql+HikariCP 操作数据库
java·数据库·maven
武子康2 小时前
Java-165 Neo4j 图论详解 欧拉路径与欧拉回路 10 分钟跑通:Python NetworkX 判定实战
java·数据库·性能优化·系统架构·nosql·neo4j·图论
岳麓丹枫0012 小时前
pg_stat 视图介绍
数据库·postgresql
弗朗凌戈2 小时前
影院票务管理系统oracle
数据库·oracle·vr
·云扬·2 小时前
MySQL主从数据一致性校验工具:pt-table-checksum 详解
数据库·sql·mysql
wudl55663 小时前
Python 虚拟环境和包管理
数据库·python·sqlite