Start Schema Benchmark (SSB)数据生成及脚本
作者:互联网
SSB 类似于TPC-H,非常适合测试分析型查询,也非常适合体现Oracle Database In-Memory的优势。
生成示例数据:
git clone https://github.com/electrum/ssb-dbgen.git
cd ssb-dbgen
sed -i 's/^MACHINE.*=.*/MACHINE=LINUX/' makefile # 将平台改为LINUX
make # 生成可执行程序dbgen
# 利用dbgen生成示例数据,-T指定表,-s指定数据放大系数
./dbgen -s 8 -T c # CUSTOMER表
./dbgen -s 24 -T p # PART表
./dbgen -s 8 -T s # SUPPLIER表
./dbgen -s 1 -T d # DATE_DIM表
./dbgen -s 2 -T l # LINEORDER表
生成表结构:
$ cat create_ssb_schema.sh
#!/bin/bash
# this script will create user SSB and 5 SSB schema tables under it
# you should input password for new created SSB user
read -sp "Please input password for user SSB you will create:" SSBPassword
echo
sqlplus / as sysdba <<-EOF
ALTER SESSION SET CONTAINER = orclpdb1;
DROP USER ssb CASCADE;
CREATE USER ssb IDENTIFIED BY "$SSBPassword";
GRANT dba, unlimited tablespace TO ssb;
ALTER SESSION SET CURRENT_SCHEMA = ssb;
CREATE TABLE lineorder (
LO_ORDERKEY number, LO_LINENUMBER number, LO_CUSTKEY number,
LO_PARTKEY number, LO_SUPPKEY number, LO_ORDERDATE number,
LO_ORDERPRIORITY char(15), LO_SHIPPRIORITY char(1), LO_QUANTITY number,
LO_EXTENDEDPRICE number, LO_ORDTOTALPRICE number, LO_DISCOUNT number,
LO_REVENUE number, LO_SUPPLYCOST number, LO_TAX number,
LO_COMMITDATE number, LO_SHIPMODE char(10));
CREATE TABLE supplier (
S_SUPPKEY number, S_NAME char(25), S_ADDRESS varchar(25), S_CITY char(10),
S_NATION char(15), S_REGION char(12), S_PHONE char(15));
CREATE TABLE part (
P_PARTKEY number, P_NAME varchar(22), P_MFGR char(6), P_CATEGORY char(7),
P_BRAND1 char(9), P_COLOR varchar(11), P_TYPE varchar(25), P_SIZE number,
P_CONTAINER char(10));
CREATE TABLE customer (
C_CUSTKEY number, C_NAME varchar(25), C_ADDRESS varchar(25),
C_CITY char(10), C_NATION char(15), C_REGION char(12), C_PHONE char(15),
C_MKTSEGMENT char(10)) ;
CREATE TABLE date_dim (
D_DATEKEY number, D_DATE char(18), D_DAYOFWEEK char(10), D_MONTH char(9),
D_YEAR number, D_YEARMONTHNUM number, D_YEARMONTH char(7),
D_DAYNUMINWEEK number, D_DAYNUMINMONTH number, D_DAYNUMINYEAR number,
D_MONTHNUMINYEAR number, D_WEEKNUMINYEAR number, D_SELLINGSEASON char(12),
D_LASTDAYINWEEKFL char(1), D_LASTDAYINMONTHFL char(1), D_HOLIDAYFL char(1),
D_WEEKDAYFL char(1)) ;
EOF
使用SQL Loader 导入Oracle数据库,以下为Control File:
$ cat customer.ctl
options (direct=true)
load data
infile 'customer.tbl'
badfile 'customer.bad'
discardfile 'customer.disc'
append
into table ssb.customer fields terminated by '|'
nullif = blanks
(
C_CUSTKEY ,
C_NAME ,
C_ADDRESS ,
C_CITY ,
C_NATION ,
C_REGION ,
C_PHONE ,
C_MKTSEGMENT
)
$ cat date.ctl
options (direct=true)
load data
infile 'date.tbl'
badfile 'date_dim.bad'
discardfile 'date_dim.disc'
append
into table ssb.date_dim fields terminated by '|'
nullif = blanks
(
D_DATEKEY ,
D_DATE ,
D_DAYOFWEEK ,
D_MONTH ,
D_YEAR ,
D_YEARMONTHNUM ,
D_YEARMONTH ,
D_DAYNUMINWEEK ,
D_DAYNUMINMONTH ,
D_DAYNUMINYEAR ,
D_MONTHNUMINYEAR ,
D_WEEKNUMINYEAR ,
D_SELLINGSEASON ,
D_LASTDAYINWEEKFL ,
D_LASTDAYINMONTHFL ,
D_HOLIDAYFL ,
D_WEEKDAYFL
)
$ cat lineorder.ctl
options (direct=true)
load data
infile 'lineorder.tbl'
badfile 'lineorder.bad'
discardfile 'lineorder.disc'
append
into table ssb.lineorder fields terminated by '|'
nullif = blanks
(LO_ORDERKEY ,
LO_LINENUMBER ,
LO_CUSTKEY ,
LO_PARTKEY ,
LO_SUPPKEY ,
LO_ORDERDATE ,
LO_ORDERPRIORITY ,
LO_SHIPPRIORITY ,
LO_QUANTITY ,
LO_EXTENDEDPRICE ,
LO_ORDTOTALPRICE ,
LO_DISCOUNT ,
LO_REVENUE ,
LO_SUPPLYCOST ,
LO_TAX ,
LO_COMMITDATE ,
LO_SHIPMODE )
$ cat part.ctl
options (direct=true)
load data
infile 'part.tbl'
badfile 'part.bad'
discardfile 'part.disc'
append
into table ssb.part fields terminated by '|'
nullif = blanks
(
P_PARTKEY ,
P_NAME ,
P_MFGR ,
P_CATEGORY ,
P_BRAND1 ,
P_COLOR ,
P_TYPE ,
P_SIZE ,
P_CONTAINER
)
$ cat supplier.ctl
options (direct=true)
load data
infile 'supplier.tbl'
badfile 'supplier.bad'
discardfile 'supplier.disc'
append
into table ssb.supplier fields terminated by '|'
nullif = blanks
(
S_SUPPKEY ,
S_NAME ,
S_ADDRESS ,
S_CITY ,
S_NATION ,
S_REGION ,
S_PHONE
)
测试SQL可以从原始论文中找,这里也有:https://github.com/Kyligence/ssb-kylin,总共13个,分为4类。
标签:load,SSB,LO,Benchmark,dbgen,cat,Start,Schema,ssb 来源: https://blog.csdn.net/stevensxiao/article/details/116045653