Sunteți pe pagina 1din 3

Written and experimented by Janusz R.

Getta, School of Computer Science and Software Engineering, University of Wollongong


Building 3, room 2120, ext 4339, jrg@uow.edu.au, http://www.uow.edu.au/jrg/317

CSCI317 Database Performan e Tuning


Experiment 1.7 How to reate and how to load TPC-H ben hmark database ?

Table of contents
Step
Step
Step
Step
Step
Step

0
1
2
3
4
5

How
How
How
How
How
How

to
to
to
to
to
to

begin and what you need to know before you start ?


create a tablespace that contains the relational tables ?
create CSCI317 user that owns the relational tables ?
create the relational tables ?
load data into the relational tables ?
discover the structures and contents of the relational tables ?

Step 0 How to begin and what you need to know before you start ?
A printable copy of this experiment in pdf format is available here (www.uow.edu.au/~jrg/317/HOMEWORK/
e1-7.pdf).
At the beginning, dowload and uncompress SQL scripts in tar.gz format (www.uow.edu.au/~jrg/317/
HOMEWORK/home1.tar.gz) or scripts in zip format (www.uow.edu.au/~jrg/317/HOMEWORK/home1.zip)
used in this homework.
In this experiment we show how to create TPC-H benchmark database on your installation of Oracle 12c server at
home. The benchmark database has been already created on all data-pc.. servers (Win 7 based servers) located
at the database lab. Therefore, there is no need to do it again. You can connect as a users CSCI317 with a
password csci317 to any Oracle 12c database servers located in the database lab. The user CSCI317 owns TPC-H
benchmark database. You can use the links listed in the References to find more information about Transaction
Processing Council and about TPC-H benchmark database.

Step 1 How to create a tablespace that contains the relational tables ?


To create and to load the sample database on Oracle 12c database server installed on your system at home, execute
the following actions. First you have to create a tablespace that contains the relational tables included in TPC-H
benchmark database. To do so connect as a user SYSTEM and execute the following statement (note, that you may
have to change a path listed after a keyword DATAFILE i.e. drive letter and path, because it is different at your
installation of Oracle 12c database server).
CREATE TABLESPACE CSCI317
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 256K
SEGMENT SPACE MANAGEMENT AUTO
BLOCKSIZE 8K
DATAFILE C:\APP\ORADATA\DB\CSCI317.DBF
SIZE 500M AUTOEXTEND ON;

Step 2 How to create CSCI317 user that owns the relational tables ?
Next, you have to create a user that owns the sample database. While connected as a user SYSTEM execute the
following statements to create a user CSCI317 with a password csci317.

CREATE USER CSCI317 IDENTIFIED BY CSCI317;


GRANT RESOURCE, CONNECT TO CSCI317;
ALTER USER CSCI317 DEFAULT TABLESPACE CSCI317;
ALTER USER CSCI317 TEMPORARY TABLESPACE TEMP;
ALTER USER CSCI317 QUOTA 500M ON CSCI317;
ALTER USER CSCI317 QUOTA 0M ON SYSTEM;
ALTER USER CSCI317 QUOTA 0M ON USERS;

Step 3 How to create the relational tables ?


To create the relational tables connect as a user CSCI317 an execute a script dbcreate.sql (www.uow.edu.au/
~jrg/317/HOMEWORK/dbcreate.sql). The relational tables can be dropped with a script dbdrop.sql (www.
uow.edu.au/~jrg/317/HOMEWORK/dbdrop.sql).

Step 4 How to load data into the relational tables ?


At this point you can load data into the relational tables. To do so put CD with synthetic data (300 Mbytes)
provided by your lecturer into your system and copy a folder TPC-HR300M to a hard drive on your system.
Next, edit a batch file dbload.bat included in a folder TPC-HR300M to set appropriate server identifer (it is a
system identifier you set up during installation of Oracle) and password for CSCI317 user.
Finally, open Command prompt window, navigate to a folder TPC-HR300M, and execute a batch file dbload.bat.
The batch file contains a call to SQL*Loader and the references to the control statements needed to load the
contents of all relational tables included in the benchmark database.

Step 5 How to discover the structures and contents of the relational tables ?
The benchmark database is frequently used in the remaining experiments. This is why, it is important to understand
a schema of the database and its contents.
Connect as a user CSCI317.
To list the names of all tables owned by the user create and execute a script list.sql (www.uow.edu.au/~jrg/
317/HOMEWORK/list.sql).
To list the descriptions of attributes and consistency constraints valid in a given table create and execute a script
tlist.sql (www.uow.edu.au/~jrg/317/HOMEWORK/tlist.sql).
To list all consistency constraints valid in all relational tables create and execute a script clist.sql (www.uow.
edu.au/~jrg/317/HOMEWORK/clist.sql).
A conceptual schema (a simplified UML class diagram) of TPC-H benchmark database can be found here (www.
uow.edu.au/~jrg/317/HOMEWORK/tpch.pdf).
To find the total number of rows in each of the relational tables execute a script dbcount.sql (www.uow.edu.
au/~jrg/317/HOMEWORK/dbcount.sql).
It is not recommended to SELECT * from the tables ! The tables are pretty large and listing of all rows will take
loooooooooong time. For example, to list the first 10 rows from a table LINEITEM execute a statement

SELECT *
FROM LINEITEM
WHERE rownum <= 10;
To list the rows between row number 10 and row number 20 and including row 10 and 20 execute a statement

SELECT *
FROM LINEITEM
WHERE rownum <= 20
MINUS
SELECT *
FROM LINEITEM
WHERE rownum < 10

References
Transaction Processing Council (TPC) Web site
(http://www.tpc.org/)
TPC-H benchmark database
(http://www.tpc.org/tpch/default.asp)

S-ar putea să vă placă și