ORACLE 19C安装测试数据库

本文档详细介绍了如何在Oracle 19C中安装和配置测试数据库,包括HR、OE等用户。首先从GitHub下载安装脚本,然后检查并创建表空间DB_SAMPLE。接着创建并解锁用户,设置环境,执行安装脚本。最后,展示了各用户如HR、OE等的表结构及其注释,为数据库测试提供了全面的指导。
摘要由CSDN通过智能技术生成

安装测试数据库

1. 目标及下载

  1. 数据库里面只安装HR用户, 19C也提供安装脚本;
  2. 19C不在提供安装脚本,需要从GITHUB上下载;
    下载地址:https://github.com/oracle/db-sample-schemas/releases/tag/v19c
    直接下载:https://codeload.github.com/oracle/db-sample-schemas/zip/refs/tags/v19c
  3. 下载后的文件:db-sample-schemas-19c.zip

1.1 安装包内容

解压后查看readme.md有内容介绍和安装步骤:

The schemas are:

  1. HR: Human Resources – 人力资源
  2. OE: Order Entry – 订单录入
  3. PM: Product Media – 产品物资
  4. IX: Information Exchange – 信息交换
  5. SH: Sales History – 销售历史
  6. BI: Business Intelligence – 商务智能

2. 安装

2.1 查看数据库情况

-- 1. 查看都有哪些表空间
select tablespace_name from dba_tablespaces;

-- 2. 查看 user 表空间中有无表存在,如果有表,则最好创建一个新的表空间
select table_name from dba_tables a where a.tablespace_name = 'USERS';

-- 3. 查看表空间, 确定数据库文件dbf存放的路径
select a.tablespace_name, a.file_name, a.bytes/1024/1024 size_m from dba_data_files a  order by a.tablespace_name;

-- 4. 创建使用的表空间: DB_SAMPLE
create tablespace DB_SAMPLE datafile '/data1/opt/oracle/app/oracle/oradata/ORCL/datafile/db_sample.dbf'
size 32M AUTOEXTEND on NEXT 32M MAXSIZE 1024M;

2.2 创建和unlock用户

-- 1. 安装时需要如下用户,否则则会出错:
specify password for SYSTEM as parameter 1:
specify password for SYS as parameter 2:

specify password for HR as parameter 3:
specify password for OE as parameter 4:
specify password for PM as parameter 5:
specify password for IX as parameter 6:
specify password for SH as parameter 7:
specify password for BI as parameter 8:


-- 根据查看的信息,可以把测试表都存放在表空间 DB_SAMPLE 中
-- 2. 创建用户, 密码都是: admin123, sys and system password is oracle
create user HR identified by hrpw default tablespace DB_SAMPLE temporary tablespace temp; 
create user OE identified by oepw default tablespace DB_SAMPLE temporary tablespace temp; 
create user PM identified by pmpw default tablespace DB_SAMPLE temporary tablespace temp; 
create user IX identified by ixpw default tablespace DB_SAMPLE temporary tablespace temp; 
create user SH identified by shpw default tablespace DB_SAMPLE temporary tablespace temp; 
create user BI identified by bipw default tablespace DB_SAMPLE temporary tablespace temp; 

-- 3. 解锁system用户
alter user  system account unlock;

-- 4. 查看已创建的用户和状态
col username format A32;
col account_status format A32;

select username, account_status from dba_users 
where username in ('SYSTEM', 'SYS', 'HR', 'OE', 'PM', 'IX', 'SH', 'BI')
;

2.3 设置环境

# 1. 进入到解压后的目录中 db-sample-schema
cd /home/oracle/apex_soft/db-sample-schemas-19c

# 2. 设置环境, 命令行下执行
perl -p -i.bak -e 's#__SUB__CWD__#'$(pwd)'#g' *.sql */*.sql */*.dat 

# 3. 设置oralce环境, 因为脚本用到了sqlldr
source /usr/local/bin/oraenv

2.4 执行安装

# 进入到解压后的目录中 db-sample-schema
cd /home/oracle/apex_soft/db-sample-schemas-19c

# 登录oracle,执行命令, 
# 注意:
# 1) oracle oracle hrpw oepw pmpw ixpw shpw bipw 分别是用户 system,sys,hr,oe,pm,ixpw,sh,bi的密码
# 2) DB_SAMPLE -- 表空间
# 3) temp       -- 临时表空间
# 4) 不用创建log目录,会自动创建
sqlplus /as sysdba
@mksample oracle oracle hrpw oepw pmpw ixpw shpw bipw DB_SAMPLE temp /home/oracle/log/ localhost:1521/orcl

# 安装后查看安装日志

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-UtYH1AHH-1646901304176)(.\img\ORACLE 19C测试数据库\image-20220309173707650.png)]

3. 测试

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-THXuLIaD-1646901304179)(img/ORACLE 19C测试数据库/image-20220310092532996.png)]

4. 表结构

-- 查询表、属主和注释
select a.owner, a.table_name, b.comments 
  from dba_tables a, ALL_TAB_COMMENTS b 
 where a.table_name = b.table_name
   and a.owner in ('HR', 'OE', 'PM', 'IX', 'SH', 'BI')
order by 1, 2;

4.1 HR

序号OWNERTABLE_NAMECOMMENTs
1HRCOUNTRIEScountry table. Contains 25 rows. References with locations table.
2HRCOUNTRIEScountry dimension table (snowflake)
3HRDEPARTMENTSDepartments table that shows details of departments where employees work. Contains 27 rows; references with locations, employees, and job_history tables.
4HREMPLOYEESemployees table. Contains 107 rows. References with departments, jobs, job_history tables. Contains a self reference.
5HRJOBSjobs table with job titles and salary ranges. Contains 19 rows. References with employees and job_history table.
6HRJOB_HISTORYTable that stores job history of the employees. If an employee changes departments within the job or changes jobs within the department, new rows get inserted into this table with old job information of the employee. Contains a complex primary key: employee_id+start_date. Contains 25 rows. References with jobs, employees, and departments tables.
7HRLOCATIONSLocations table that contains specific address of a specific office, warehouse, and/or production site of a company. Does not store addresses / locations of customers. Contains 23 rows; references with the departments and countries tables.

4.2 OE

序号OWNERTABLE_NAMECOMMENTs
1OECUSTOMERSdimension table
2OECUSTOMERSContains customers data either entered by an employee or by the customer him/herself over the Web.
3OEINVENTORIESTracks availability of products by product_it and warehouse_id.
4OEORDERSContains orders entered by a salesperson as well as over the Web.
5OEORDER_ITEMSExample of many-to-many resolution.
6OEPRODUCT_DESCRIPTIONSNon-industry-specific design, allows selection of NLS-setting-specific data derived at runtime, for example using the products view.
7OEPRODUCT_INFORMATIONNon-industry-specific data in various categories.
8OEPROMOTIONS
9OEPROMOTIONSdimension table without a PK-FK relationship with the facts table, to show outer join functionality
10OEWAREHOUSESWarehouse data unspecific to any industry.

4.3 PM

序号OWNERTABLE_NAMECOMMENTs
1PMPRINT_MEDIA

4.4 IX

序号OWNERTABLE_NAMECOMMENTs
1IXAQ$_ORDERS_QUEUETABLE_G
2IXAQ$_ORDERS_QUEUETABLE_H
3IXAQ$_ORDERS_QUEUETABLE_I
4IXAQ$_ORDERS_QUEUETABLE_L
5IXAQ$_ORDERS_QUEUETABLE_S
6IXAQ$_ORDERS_QUEUETABLE_T
7IXAQ$_STREAMS_QUEUE_TABLE_C
8IXAQ$_STREAMS_QUEUE_TABLE_G
9IXAQ$_STREAMS_QUEUE_TABLE_H
10IXAQ$_STREAMS_QUEUE_TABLE_I
11IXAQ$_STREAMS_QUEUE_TABLE_L
12IXAQ$_STREAMS_QUEUE_TABLE_S
13IXAQ$_STREAMS_QUEUE_TABLE_T
14IXORDERS_QUEUETABLE
15IXSTREAMS_QUEUE_TABLE

4.5 SH

序号OWNERTABLE_NAMECOMMENTs
1SHCHANNELSsmall dimension table
2SHCOSTS
3SHCOUNTRIEScountry dimension table (snowflake)
4SHCOUNTRIEScountry table. Contains 25 rows. References with locations table.
5SHCUSTOMERSdimension table
6SHCUSTOMERSContains customers data either entered by an employee or by the customer him/herself over the Web.
7SHDR S U P T E X T I D X SUP_TEXT_IDX SUPTEXTIDXI
8SHDR S U P T E X T I D X SUP_TEXT_IDX SUPTEXTIDXK
9SHDR S U P T E X T I D X SUP_TEXT_IDX SUPTEXTIDXN
10SHDR S U P T E X T I D X SUP_TEXT_IDX SUPTEXTIDXU
11SHPRODUCTSdimension table
12SHPRODUCTSThis view joins product_information and product_descriptions, using NLS settings to pick the appropriate language-specific product description.
13SHPROMOTIONSdimension table without a PK-FK relationship with the facts table, to show outer join functionality
14SHPROMOTIONS
15SHSALESfacts table, without a primary key; all rows are uniquely identified by the combination of all foreign keys
16SHSALES_TRANSACTIONS_EXT
17SHSUPPLEMENTARY_DEMOGRAPHICS
18SHTIMESTime dimension table to support multiple hierarchies and materialized views

4.6 BI

BI用户主要是新增和使用数据;

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

若行若冲

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值