在Sakila——MySQL样例数据库解析 中,学习了sakila for mysql的表结构。并把它作为数据仓库、ODI ETL学习的源数据库。ODI Studio拓扑结构的创建与配置 后来发现ODI 自带的mysql的KM比较少,所以还是以Oracle版本的sakila 作为了练习的源数据库。
下载地址:
https://code.google.com/p/sakila-sample-database-ports/downloads/ 需要翻_墙
解压后发现有各种数据库的实现。
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJoAAACWCAIAAACpXwY7AAAJkklEQVR4nO2d628UVRiH538y2X9AiEFjYxrTD0IBB0UbFfAuJo2ABuwkNcQvhpjwhUDEoF2wchNoS0uhpa1chl7p0pbeXUtbtp30guuH6c6cOZe57J6dy9v3CSHd2TmXOb+Z2WnPk7PKkWPH8/l8TU2NUQIvnch37VXw/8j/V6TEicQEjBMU4jj/+W1p6ofceP3iSN1C5vuF4bpnQ0fnBr7N9h2afVQ726/NT16PosOIG6I4l5em6teWz79Ym8nNnvj3ybHH3QdXl669WL1p/lvJXZzSj0bTZUSM8OpcmqpfMxrXjMZ8fj2fXx+5W/Oo/Zvlud/XV5rWjL9Wc5fGuz+JpMeIC95xrhmN+Xx++M4795u/mnhweDV3aWXxvPHs3FjXAboyXUspKU2X1TddSylqWlZtpcDriX2wabXobqbVwoDJOVhxnJNknOuDbbvu3fjs6d+1xrNzS9nTz2dOjnbuoyvDOIMSWpzPJzQzy5Wl9H8vcn3Nb/Vc2zfa9cXzmZOLEz/Njx1/0vFBwLaC9jjecdokIc7Fp9+bWRoLv66vTuvXq7qvvD/ScWB+7Phcpi47eGSsa//04KkgbWGcvKLhxDk/8p2ZZS57anmh/cHVyrsX386012QHj8z2fT398NPJex89vvWuo4zdpbSqpDRNVRRFUcwOpzdeFF6TWwo3aLN8Wt3YRLxUFEUhjlbXUsxG3ja2CRpOKcGmjZ/Nd9W082BdyrIQQ2H3THywQRDGOZc5bGY5P/VzdvTHe5cqOi5sf3xzjxnkePfebDY71LqHGRvrCAs9sj9jyBPQPi2J7dZQkWNDlLBqV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6lTxiLR9FrX4lj2TGGbr6lRRiLR/FR/1KCsmMMyT1i8G9Bqftk1YL85MOs0goj5GlODMBAFyyqNUvCn4NrAbG2FZu31AnKOXddPJcsqjVL0+hi6+BUWNfqNfhtPgp5dq0YQ8tcZHE2iWLWv3iI65BcITmXrq1mpi/Uh5NJ9Ali1r9ovCowdLAmCPUtVRKVe214fyVcm86gS5Z1OoX9xCpGtyfR8idyE2+Srk3nTyXDNUvUKD6BQpUv0CB09egwDhBgXGCAuMEBcYJiv8BtR2GK3r1uTEAAAAASUVORK5CYII=" alt="" />
在oracle数据库创建sakila用户
用于执行以下的各个sql
/*第1步:创建临时表空间 */
create temporary tablespace odi_temp
tempfile 'C:\app\ORACLE\oradata\orcl\odi_temp.dbf'
size 50m
autoextend on
next 50m maxsize 20480m
extent management local; /*第2步:创建数据表空间 */
create tablespace odi_data
logging
datafile 'C:\app\ORACLE\oradata\orcl\odi_data.dbf'
size 50m
autoextend on
next 50m maxsize 20480m
extent management local; /*第3步:创建用户并指定表空间 */
create user sakila identified by sakila
default tablespace odi_data
temporary tablespace odi_temp
quota unlimited on odi_data
profile default ; /*第4步:给用户授予权限 */
grant connect,resource to sakila;
grant create view to sakila;
oracle-sakila-schema.sql
- 需要修改下sequence
- 触发器在navicat下执行也有问题,报错信息ORA-24344: 成功, 但出现编译错误, 参照http://javawangzilong.iteye.com/blog/2144309把END IF ; *** ,END; 放在一行即可)
- actor_info 视图当前不可用,有空改掉
- procedure和function当前未支持
/* Sakila for Oracle is a port of the Sakila example database available for MySQL, which was originally developed by Mike Hillyer of the MySQL AB documentation team.
This project is designed to help database administrators to decide which database to use for development of new products
The user can run the same SQL against different kind of databases and compare the performance License: BSD
Copyright DB Software Laboratory
http://www.etl-tools.com */ --
-- Table structure for table actor
--
--DROP TABLE actor; CREATE TABLE actor (
actor_id numeric NOT NULL ,
first_name VARCHAR(45) NOT NULL,
last_name VARCHAR(45) NOT NULL,
last_update DATE NOT NULL,
PRIMARY KEY (actor_id)
); CREATE INDEX idx_actor_last_name ON actor(last_name); --DROP SEQUENCE actor_sequence; CREATE SEQUENCE actor_sequence
INCREMENT BY 1
START WITH 1
MINVALUE 1 NOMAXVALUE
NOCYCLE ; CREATE OR REPLACE TRIGGER actor_before_trigger
BEFORE INSERT ON actor FOR EACH ROW
BEGIN
IF (:NEW.actor_id IS NULL) THEN
SELECT actor_sequence.nextval INTO :NEW.actor_id
FROM DUAL;
END IF;:NEW.last_update:=current_date;END; CREATE OR REPLACE TRIGGER actor_before_update
BEFORE UPDATE ON actor FOR EACH ROW
BEGIN
:NEW.last_update:=current_date;
END; --
-- Table structure for table country
-- CREATE TABLE country (
country_id SMALLINT NOT NULL,
country VARCHAR(50) NOT NULL,
last_update DATE,
PRIMARY KEY (country_id)
); ---DROP SEQUENCE country_sequence; CREATE SEQUENCE country_sequence
INCREMENT BY 1
START WITH 1
MINVALUE 1 NOMAXVALUE
NOCYCLE ; CREATE OR REPLACE TRIGGER country_before_trigger
BEFORE INSERT ON country FOR EACH ROW
BEGIN
IF (:NEW.country_id IS NULL) THEN
SELECT country_sequence.nextval INTO :NEW.country_id
FROM DUAL;
END IF;:NEW.last_update:=current_date;END; CREATE OR REPLACE TRIGGER country_before_update
BEFORE UPDATE ON country FOR EACH ROW
BEGIN
:NEW.last_update:=current_date;
END; --
-- Table structure for table city
-- CREATE TABLE city (
city_id int NOT NULL,
city VARCHAR(50) NOT NULL,
country_id SMALLINT NOT NULL,
last_update DATE NOT NULL,
PRIMARY KEY (city_id),
CONSTRAINT fk_city_country FOREIGN KEY (country_id) REFERENCES country (country_id)
); CREATE INDEX idx_fk_country_id ON city(country_id); --- DROP SEQUENCE city_sequence; CREATE SEQUENCE city_sequence
INCREMENT BY 1
START WITH 1
MINVALUE 1 NOMAXVALUE
NOCYCLE ; CREATE OR REPLACE TRIGGER city_before_trigger
BEFORE INSERT ON city FOR EACH ROW
BEGIN
IF (:NEW.city_id IS NULL) THEN
SELECT city_sequence.nextval INTO :NEW.city_id
FROM DUAL;
END IF;:NEW.last_update:=current_date;END; CREATE OR REPLACE TRIGGER city_before_update
BEFORE UPDATE ON city FOR EACH ROW
BEGIN
:NEW.last_update:=current_date;
END; --
-- Table structure for table address
-- CREATE TABLE address (
address_id int NOT NULL,
address VARCHAR(50) NOT NULL,
address2 VARCHAR(50) DEFAULT NULL,
district VARCHAR(20) NOT NULL,
city_id INT NOT NULL,
postal_code VARCHAR(10) DEFAULT NULL,
phone VARCHAR(20) NOT NULL,
last_update DATE NOT NULL,
PRIMARY KEY (address_id)
); CREATE INDEX idx_fk_city_id ON address(city_id); ALTER TABLE address ADD CONSTRAINT fk_address_city FOREIGN KEY (city_id) REFERENCES city (city_id); --DROP SEQUENCE city_sequence; CREATE SEQUENCE address_sequence
INCREMENT BY 1
START WITH 1
MINVALUE 1 NOMAXVALUE
NOCYCLE ; CREATE OR REPLACE TRIGGER address_before_trigger
BEFORE INSERT ON address FOR EACH ROW
BEGIN
IF (:NEW.address_id IS NULL) THEN
SELECT address_sequence.nextval INTO :NEW.address_id
FROM DUAL;
END IF;:NEW.last_update:=current_date;END; CREATE OR REPLACE TRIGGER address_before_update
BEFORE UPDATE ON address FOR EACH ROW
BEGIN
:NEW.last_update:=current_date;
END; --
-- Table structure for table language
-- CREATE TABLE language (
language_id SMALLINT NOT NULL ,
name CHAR(20) NOT NULL,
last_update DATE NOT NULL,
PRIMARY KEY (language_id)
); ---DROP SEQUENCE language_sequence; CREATE SEQUENCE language_sequence
INCREMENT BY 1
START WITH 1
MINVALUE 1 NOMAXVALUE
NOCYCLE ; CREATE OR REPLACE TRIGGER language_before_trigger
BEFORE INSERT ON language FOR EACH ROW
BEGIN
IF (:NEW.language_id IS NULL) THEN
SELECT language_sequence.nextval INTO :NEW.language_id
FROM DUAL;
END IF;:NEW.last_update:=current_date;END; CREATE OR REPLACE TRIGGER language_before_update
BEFORE UPDATE ON language FOR EACH ROW
BEGIN
:NEW.last_update:=current_date;
END; --
-- Table structure for table category
-- CREATE TABLE category (
category_id SMALLINT NOT NULL,
name VARCHAR(25) NOT NULL,
last_update DATE NOT NULL,
PRIMARY KEY (category_id)
); ---DROP SEQUENCE category_sequence; CREATE SEQUENCE category_sequence
INCREMENT BY 1
START WITH 1
MINVALUE 1 NOMAXVALUE
NOCYCLE ; CREATE OR REPLACE TRIGGER category_before_trigger
BEFORE INSERT ON category FOR EACH ROW
BEGIN
IF (:NEW.category_id IS NULL) THEN
SELECT category_sequence.nextval INTO :NEW.category_id
FROM DUAL;
END IF;:NEW.last_update:=current_date;END; CREATE OR REPLACE TRIGGER category_before_update
BEFORE UPDATE ON category FOR EACH ROW
BEGIN
:NEW.last_update:=current_date;
END; --
-- Table structure for table customer
-- CREATE TABLE customer (
customer_id INT NOT NULL,
store_id INT NOT NULL,
first_name VARCHAR(45) NOT NULL,
last_name VARCHAR(45) NOT NULL,
email VARCHAR(50) DEFAULT NULL,
address_id INT NOT NULL,
active CHAR(1) DEFAULT 'Y' NOT NULL,
create_date DATE NOT NULL,
last_update DATE NOT NULL,
PRIMARY KEY (customer_id),
CONSTRAINT fk_customer_address FOREIGN KEY (address_id) REFERENCES address(address_id)
); CREATE INDEX idx_customer_fk_store_id ON customer(store_id); CREATE INDEX idx_customer_fk_address_id ON customer(address_id); CREATE INDEX idx_customer_last_name ON customer(last_name); ---DROP SEQUENCE customer_sequence; CREATE SEQUENCE customer_sequence
INCREMENT BY 1
START WITH 1
MINVALUE 1 NOMAXVALUE
NOCYCLE ; CREATE OR REPLACE TRIGGER customer_before_trigger
BEFORE INSERT ON customer FOR EACH ROW
BEGIN
IF (:NEW.customer_id IS NULL) THEN
SELECT customer_sequence.nextval INTO :NEW.customer_id
FROM DUAL;
END IF;:NEW.last_update:=current_date;:NEW.create_date:=current_date;END; CREATE OR REPLACE TRIGGER customer_before_update
BEFORE UPDATE ON customer FOR EACH ROW
BEGIN
:NEW.last_update:=current_date;
END; --
-- Table structure for table film
-- CREATE TABLE film (
film_id int NOT NULL,
title VARCHAR(255) NOT NULL,
description CLOB DEFAULT NULL,
release_year VARCHAR(4) DEFAULT NULL,
language_id SMALLINT NOT NULL,
original_language_id SMALLINT DEFAULT NULL,
rental_duration SMALLINT DEFAULT 3 NOT NULL,
rental_rate DECIMAL(4,2) DEFAULT 4.99 NOT NULL,
length SMALLINT DEFAULT NULL,
replacement_cost DECIMAL(5,2) DEFAULT 19.99 NOT NULL,
rating VARCHAR(10) DEFAULT 'G',
special_features VARCHAR(100) DEFAULT NULL,
last_update DATE NOT NULL,
PRIMARY KEY (film_id),
CONSTRAINT fk_film_language FOREIGN KEY (language_id) REFERENCES language (language_id) ,
CONSTRAINT fk_film_language_original FOREIGN KEY (original_language_id) REFERENCES language (language_id)
); ALTER TABLE film ADD CONSTRAINT CHECK_special_features CHECK(special_features is null or
special_features like '%Trailers%' or
special_features like '%Commentaries%' or
special_features like '%Deleted Scenes%' or
special_features like '%Behind the Scenes%'); ALTER TABLE film ADD CONSTRAINT CHECK_special_rating CHECK(rating in ('G','PG','PG-13','R','NC-17')); CREATE INDEX idx_fk_language_id ON film(language_id); CREATE INDEX idx_fk_original_language_id ON film(original_language_id); ---DROP SEQUENCE film_sequence; CREATE SEQUENCE film_sequence
INCREMENT BY 1
START WITH 1
MINVALUE 1 NOMAXVALUE
NOCYCLE ; CREATE OR REPLACE TRIGGER film_before_trigger
BEFORE INSERT ON film FOR EACH ROW
BEGIN
IF (:NEW.film_id IS NULL) THEN
SELECT film_sequence.nextval INTO :NEW.film_id
FROM DUAL;
END IF;:NEW.last_update:=current_date;END; CREATE OR REPLACE TRIGGER film_before_update
BEFORE UPDATE ON film FOR EACH ROW
BEGIN
:NEW.last_update:=current_date;
END; --
-- Table structure for table film_actor
-- CREATE TABLE film_actor (
actor_id INT NOT NULL,
film_id INT NOT NULL,
last_update DATE NOT NULL,
PRIMARY KEY (actor_id,film_id),
CONSTRAINT fk_film_actor_actor FOREIGN KEY (actor_id) REFERENCES actor (actor_id),
CONSTRAINT fk_film_actor_film FOREIGN KEY (film_id) REFERENCES film (film_id)
); CREATE INDEX idx_fk_film_actor_film ON film_actor(film_id); CREATE INDEX idx_fk_film_actor_actor ON film_actor(actor_id) ; CREATE OR REPLACE TRIGGER film_actor_before_trigger
BEFORE INSERT ON film_actor FOR EACH ROW
BEGIN
:NEW.last_update:=current_date;
END; CREATE OR REPLACE TRIGGER film_actor_before_update
BEFORE UPDATE ON film_actor FOR EACH ROW
BEGIN
:NEW.last_update:=current_date;
END; --
-- Table structure for table film_category
-- CREATE TABLE film_category (
film_id INT NOT NULL,
category_id SMALLINT NOT NULL,
last_update DATE NOT NULL,
PRIMARY KEY (film_id, category_id),
CONSTRAINT fk_film_category_film FOREIGN KEY (film_id) REFERENCES film (film_id),
CONSTRAINT fk_film_category_category FOREIGN KEY (category_id) REFERENCES category (category_id)
); CREATE INDEX idx_fk_film_category_film ON film_category(film_id); CREATE INDEX idx_fk_film_category_category ON film_category(category_id); CREATE OR REPLACE TRIGGER film_category_before_trigger
BEFORE INSERT ON film_category FOR EACH ROW
BEGIN
:NEW.last_update:=current_date;
END; CREATE OR REPLACE TRIGGER film_category_before_update
BEFORE UPDATE ON film_category FOR EACH ROW
BEGIN
:NEW.last_update:=current_date;
END; --
-- Table structure for table film_text
-- CREATE TABLE film_text (
film_id SMALLINT NOT NULL,
title VARCHAR(255) NOT NULL,
description CLOB,
PRIMARY KEY (film_id)
); --
-- Table structure for table inventory
-- CREATE TABLE inventory (
inventory_id INT NOT NULL,
film_id INT NOT NULL,
store_id INT NOT NULL,
last_update DATE NOT NULL,
PRIMARY KEY (inventory_id),
CONSTRAINT fk_inventory_film FOREIGN KEY (film_id) REFERENCES film (film_id)
); CREATE INDEX idx_fk_film_id ON inventory(film_id); CREATE INDEX idx_fk_film_id_store_id ON inventory(store_id,film_id); ---DROP SEQUENCE inventory_sequence; CREATE SEQUENCE inventory_sequence
INCREMENT BY 1
START WITH 1
MINVALUE 1 NOMAXVALUE
NOCYCLE ; CREATE OR REPLACE TRIGGER inventory_before_trigger
BEFORE INSERT ON inventory FOR EACH ROW
BEGIN
IF (:NEW.inventory_id IS NULL) THEN
SELECT inventory_sequence.nextval INTO :NEW.inventory_id
FROM DUAL;
END IF;:NEW.last_update:=current_date;END; CREATE OR REPLACE TRIGGER inventory_before_update
BEFORE UPDATE ON inventory FOR EACH ROW
BEGIN
:NEW.last_update:=current_date;
END; --
-- Table structure for table staff
-- CREATE TABLE staff (
staff_id SMALLINT NOT NULL,
first_name VARCHAR(45) NOT NULL,
last_name VARCHAR(45) NOT NULL,
address_id INT NOT NULL,
picture BLOB DEFAULT NULL,
email VARCHAR(50) DEFAULT NULL,
store_id INT NOT NULL,
active SMALLINT DEFAULT 1 NOT NULL,
username VARCHAR(16) NOT NULL,
password VARCHAR(40) DEFAULT NULL,
last_update DATE NOT NULL,
PRIMARY KEY (staff_id),
CONSTRAINT fk_staff_address FOREIGN KEY (address_id) REFERENCES address (address_id)
); CREATE INDEX idx_fk_staff_store_id ON staff(store_id); CREATE INDEX idx_fk_staff_address_id ON staff(address_id); ---DROP SEQUENCE inventory_sequence; CREATE SEQUENCE staff_sequence
INCREMENT BY 1
START WITH 1
MINVALUE 1 NOMAXVALUE
NOCYCLE ; CREATE OR REPLACE TRIGGER staff_before_trigger
BEFORE INSERT ON staff FOR EACH ROW
BEGIN
IF (:NEW.staff_id IS NULL) THEN
SELECT staff_sequence.nextval INTO :NEW.staff_id
FROM DUAL;
END IF;:NEW.last_update:=current_date;END; CREATE OR REPLACE TRIGGER staff_before_update
BEFORE UPDATE ON staff FOR EACH ROW
BEGIN
:NEW.last_update:=current_date;
END; --
-- Table structure for table store
-- CREATE TABLE store (
store_id INT NOT NULL,
manager_staff_id SMALLINT NOT NULL,
address_id INT NOT NULL,
last_update DATE NOT NULL,
PRIMARY KEY (store_id),
CONSTRAINT fk_store_staff FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id) ,
CONSTRAINT fk_store_address FOREIGN KEY (address_id) REFERENCES address (address_id)
); CREATE INDEX idx_store_fk_manager_staff_id ON store(manager_staff_id); CREATE INDEX idx_fk_store_address ON store(address_id); ---DROP SEQUENCE store_sequence; CREATE SEQUENCE store_sequence
INCREMENT BY 1
START WITH 1
MINVALUE 1 NOMAXVALUE
NOCYCLE ; CREATE OR REPLACE TRIGGER store_before_trigger
BEFORE INSERT ON store FOR EACH ROW
BEGIN
IF (:NEW.store_id IS NULL) THEN
SELECT store_sequence.nextval INTO :NEW.store_id
FROM DUAL;
END IF;:NEW.last_update:=current_date;END; CREATE OR REPLACE TRIGGER store_before_update
BEFORE UPDATE ON store FOR EACH ROW
BEGIN
:NEW.last_update:=current_date;
END; --
-- Table structure for table payment
-- CREATE TABLE payment (
payment_id int NOT NULL,
customer_id INT NOT NULL,
staff_id SMALLINT NOT NULL,
rental_id INT DEFAULT NULL,
amount DECIMAL(5,2) NOT NULL,
payment_date DATE NOT NULL,
last_update DATE NOT NULL,
PRIMARY KEY (payment_id),
CONSTRAINT fk_payment_customer FOREIGN KEY (customer_id) REFERENCES customer (customer_id) ,
CONSTRAINT fk_payment_staff FOREIGN KEY (staff_id) REFERENCES staff (staff_id)
); CREATE INDEX idx_fk_staff_id ON payment(staff_id); CREATE INDEX idx_fk_customer_id ON payment(customer_id); ---DROP SEQUENCE payment_sequence; CREATE SEQUENCE payment_sequence
INCREMENT BY 1
START WITH 1
MINVALUE 1 NOMAXVALUE
NOCYCLE ; CREATE OR REPLACE TRIGGER payment_before_trigger
BEFORE INSERT ON payment FOR EACH ROW
BEGIN
IF (:NEW.payment_id IS NULL) THEN
SELECT payment_sequence.nextval INTO :NEW.payment_id
FROM DUAL;
END IF;:NEW.last_update:=current_date;END; CREATE OR REPLACE TRIGGER payment_before_update
BEFORE UPDATE ON payment FOR EACH ROW
BEGIN
:NEW.last_update:=current_date;
END; CREATE TABLE rental (
rental_id INT NOT NULL,
rental_date DATE NOT NULL,
inventory_id INT NOT NULL,
customer_id INT NOT NULL,
return_date DATE DEFAULT NULL,
staff_id SMALLINT NOT NULL,
last_update DATE NOT NULL,
PRIMARY KEY (rental_id),
CONSTRAINT fk_rental_staff FOREIGN KEY (staff_id) REFERENCES staff (staff_id) ,
CONSTRAINT fk_rental_inventory FOREIGN KEY (inventory_id) REFERENCES inventory (inventory_id) ,
CONSTRAINT fk_rental_customer FOREIGN KEY (customer_id) REFERENCES customer (customer_id)
); CREATE INDEX idx_rental_fk_inventory_id ON rental(inventory_id); CREATE INDEX idx_rental_fk_customer_id ON rental(customer_id); CREATE INDEX idx_rental_fk_staff_id ON rental(staff_id); CREATE UNIQUE INDEX idx_rental_uq ON rental (rental_date,inventory_id,customer_id); ---DROP SEQUENCE payment_sequence; CREATE SEQUENCE rental_sequence
INCREMENT BY 1
START WITH 1
MINVALUE 1 NOMAXVALUE
NOCYCLE ; CREATE OR REPLACE TRIGGER rental_before_trigger
BEFORE INSERT ON rental FOR EACH ROW
BEGIN
IF (:NEW.rental_id IS NULL) THEN
SELECT rental_sequence.nextval INTO :NEW.rental_id
FROM DUAL;
END IF;:NEW.last_update:=current_date;END; CREATE OR REPLACE TRIGGER rental_before_update
BEFORE UPDATE ON rental FOR EACH ROW
BEGIN
:NEW.last_update:=current_date;
END; -- FK CONSTRAINTS
ALTER TABLE customer ADD CONSTRAINT fk_customer_store FOREIGN KEY (store_id) REFERENCES store (store_id); ALTER TABLE inventory ADD CONSTRAINT fk_inventory_store FOREIGN KEY (store_id) REFERENCES store (store_id); ALTER TABLE staff ADD CONSTRAINT fk_staff_store FOREIGN KEY (store_id) REFERENCES store (store_id); ALTER TABLE payment ADD CONSTRAINT fk_payment_rental FOREIGN KEY (rental_id) REFERENCES rental (rental_id) ON DELETE SET NULL; --
-- View structure for view customer_list
-- CREATE OR REPLACE VIEW customer_list
AS
SELECT cu.customer_id AS ID,
cu.first_name||' '||cu.last_name AS name,
a.address AS address,
a.postal_code AS zip_code,
a.phone AS phone,
city.city AS city,
country.country AS country,
decode(cu.active, 1,'active','') AS notes,
cu.store_id AS SID
FROM customer cu JOIN address a ON cu.address_id = a.address_id JOIN city ON a.city_id = city.city_id
JOIN country ON city.country_id = country.country_id; --
-- View structure for view film_list
-- CREATE OR REPLACE VIEW film_list
AS
SELECT film.film_id AS FID,
film.title AS title,
film.description AS description,
category.name AS category,
film.rental_rate AS price,
film.length AS length,
film.rating AS rating,
actor.first_name||' '||actor.last_name AS actors
FROM category LEFT JOIN film_category ON category.category_id = film_category.category_id LEFT JOIN film ON film_category.film_id = film.film_id
JOIN film_actor ON film.film_id = film_actor.film_id
JOIN actor ON film_actor.actor_id = actor.actor_id; --
-- View structure for view staff_list
-- CREATE OR REPLACE VIEW staff_list
AS
SELECT s.staff_id AS ID,
s.first_name||' '||s.last_name AS name,
a.address AS address,
a.postal_code AS zip_code,
a.phone AS phone,
city.city AS city,
country.country AS country,
s.store_id AS SID
FROM staff s JOIN address a ON s.address_id = a.address_id JOIN city ON a.city_id = city.city_id
JOIN country ON city.country_id = country.country_id; --
-- View structure for view sales_by_store
-- CREATE OR REPLACE VIEW sales_by_store
AS
SELECT
s.store_id
,c.city||','||cy.country AS store
,m.first_name||' '||m.last_name AS manager
,SUM(p.amount) AS total_sales
FROM payment p
INNER JOIN rental r ON p.rental_id = r.rental_id
INNER JOIN inventory i ON r.inventory_id = i.inventory_id
INNER JOIN store s ON i.store_id = s.store_id
INNER JOIN address a ON s.address_id = a.address_id
INNER JOIN city c ON a.city_id = c.city_id
INNER JOIN country cy ON c.country_id = cy.country_id
INNER JOIN staff m ON s.manager_staff_id = m.staff_id
GROUP BY
s.store_id
, c.city||','||cy.country
, m.first_name||' '||m.last_name; --
-- View structure for view sales_by_film_category
--
-- Note that total sales will add up to >100% because
-- some titles belong to more than 1 category
-- CREATE OR REPLACE VIEW sales_by_film_category
AS
SELECT
c.name AS category
, SUM(p.amount) AS total_sales
FROM payment p
INNER JOIN rental r ON p.rental_id = r.rental_id
INNER JOIN inventory i ON r.inventory_id = i.inventory_id
INNER JOIN film f ON i.film_id = f.film_id
INNER JOIN film_category fc ON f.film_id = fc.film_id
INNER JOIN category c ON fc.category_id = c.category_id
GROUP BY c.name; --
-- View structure for view actor_info
-- /*
CREATE VIEW actor_info
AS
SELECT
a.actor_id,
a.first_name,
a.last_name,
GROUP_CONCAT(DISTINCT CONCAT(c.name, ': ',
(SELECT GROUP_CONCAT(f.title ORDER BY f.title SEPARATOR ', ')
FROM sakila.film f
INNER JOIN sakila.film_category fc
ON f.film_id = fc.film_id
INNER JOIN sakila.film_actor fa
ON f.film_id = fa.film_id
WHERE fc.category_id = c.category_id
AND fa.actor_id = a.actor_id
)
)
ORDER BY c.name SEPARATOR '; ')
AS film_info
FROM sakila.actor a
LEFT JOIN sakila.film_actor fa
ON a.actor_id = fa.actor_id
LEFT JOIN sakila.film_category fc
ON fa.film_id = fc.film_id
LEFT JOIN sakila.category c
ON fc.category_id = c.category_id
GROUP BY a.actor_id, a.first_name, a.last_name; */
-- TO DO PROCEDURES
oracle-sakila-insert-data.sql
oracle-sakila-delete-data.sql
/* Sakila for Oracle is a port of the Sakila example database available for MySQL, which was originally developed by Mike Hillyer of the MySQL AB documentation team.
This project is designed to help database administrators to decide which database to use for development of new products
The user can run the same SQL against different kind of databases and compare the performance License: BSD
Copyright DB Software Laboratory
http://www.etl-tools.com */ -- Delete data
ALTER TABLE staff DROP CONSTRAINT fk_staff_address;
ALTER TABLE staff DROP CONSTRAINT fk_staff_store;
ALTER TABLE store DROP CONSTRAINT fk_store_staff;
DELETE FROM payment ;
DELETE FROM rental ;
DELETE FROM customer ;
DELETE FROM film_category ;
DELETE FROM film_text ;
DELETE FROM film_actor ;
DELETE FROM inventory ;
DELETE FROM film ;
DELETE FROM category ;
DELETE FROM staff ;
DELETE FROM store ;
DELETE FROM actor ;
DELETE FROM address ;
DELETE FROM city ;
DELETE FROM country ;
DELETE FROM language ;
ALTER TABLE staff ADD CONSTRAINT fk_staff_address FOREIGN KEY (address_id) REFERENCES address (address_id);
ALTER TABLE staff ADD CONSTRAINT fk_staff_store FOREIGN KEY (store_id) REFERENCES store (store_id);
ALTER TABLE store ADD CONSTRAINT fk_store_staff FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id);
oracle-sakila-drop-objects.sql
/* Sakila for Oracle is a port of the Sakila example database available for MySQL, which was originally developed by Mike Hillyer of the MySQL AB documentation team.
This project is designed to help database administrators to decide which database to use for development of new products
The user can run the same SQL against different kind of databases and compare the performance License: BSD
Copyright DB Software Laboratory
http://www.etl-tools.com */ -- Drop Views DROP VIEW customer_list;
DROP VIEW film_list;
--DROP VIEW nicer_but_slower_film_list;
DROP VIEW sales_by_film_category;
DROP VIEW sales_by_store;
DROP VIEW staff_list; -- Drop Tables DROP TABLE payment;
DROP TABLE rental;
DROP TABLE inventory;
DROP TABLE film_text;
DROP TABLE film_category;
DROP TABLE film_actor;
DROP TABLE film;
DROP TABLE language;
DROP TABLE customer;
DROP TABLE actor;
DROP TABLE category;
ALTER TABLE staff DROP CONSTRAINT fk_staff_address;
ALTER TABLE store DROP CONSTRAINT fk_store_staff;
ALTER TABLE staff DROP CONSTRAINT fk_staff_store;
DROP TABLE store;
DROP TABLE address;
DROP TABLE staff;
DROP TABLE city;
DROP TABLE country; -- Procedures and views
--drop procedure film_in_stock;
--drop procedure film_not_in_stock;
--drop function get_customer_balance;
--drop function inventory_held_by_customer;
--drop function inventory_in_stock;
--drop procedure rewards_report; -- DROP SEQUENCES
DROP SEQUENCE ACTOR_SEQUENCE;
DROP SEQUENCE ADDRESS_SEQUENCE;
DROP SEQUENCE CATEGORY_SEQUENCE;
DROP SEQUENCE CITY_SEQUENCE;
DROP SEQUENCE COUNTRY_SEQUENCE;
DROP SEQUENCE CUSTOMER_SEQUENCE;
DROP SEQUENCE FILM_SEQUENCE;
DROP SEQUENCE INVENTORY_SEQUENCE;
DROP SEQUENCE LANGUAGE_SEQUENCE;
DROP SEQUENCE PAYMENT_SEQUENCE;
DROP SEQUENCE RENTAL_SEQUENCE;
DROP SEQUENCE STAFF_SEQUENCE;
DROP SEQUENCE STORE_SEQUENCE;
验证:
每个表的记录条数和mysql自带的sakila一致
SELECT 'ACTOR' AS TABLENAME, COUNT(*) AS RECORDSIZE FROM ACTOR UNION ALL
SELECT 'ADDRESS' , COUNT(*) FROM ADDRESS UNION ALL
SELECT 'CATEGORY' , COUNT(*) FROM CATEGORY UNION ALL
SELECT 'CITY' , COUNT(*) FROM CITY UNION ALL
SELECT 'COUNTRY' , COUNT(*) FROM COUNTRY UNION ALL
SELECT 'CUSTOMER' , COUNT(*) FROM CUSTOMER UNION ALL
SELECT 'FILM' , COUNT(*) FROM FILM UNION ALL
SELECT 'FILM_ACTOR' , COUNT(*) FROM FILM_ACTOR UNION ALL
SELECT 'FILM_CATEGORY' , COUNT(*) FROM FILM_CATEGORY UNION ALL
SELECT 'FILM_TEXT' , COUNT(*) FROM FILM_TEXT UNION ALL
SELECT 'INVENTORY' , COUNT(*) FROM INVENTORY UNION ALL
SELECT 'LANGUAGE' , COUNT(*) FROM LANGUAGE UNION ALL
SELECT 'PAYMENT' , COUNT(*) FROM PAYMENT UNION ALL
SELECT 'RENTAL' , COUNT(*) FROM RENTAL UNION ALL
SELECT 'STAFF' , COUNT(*) FROM STAFF UNION ALL
SELECT 'STORE' , COUNT(*) FROM STORE
修改sequence的nextval值
开始创建的sequence都是1,执行了oracle-sakila-insert-data.sql后,因为触发器上有判断NULL(如IF (:NEW.actor_id IS NULL)),
CREATE OR REPLACE TRIGGER actor_before_trigger
BEFORE INSERT ON actor FOR EACH ROW
BEGIN
IF (:NEW.actor_id IS NULL) THEN
SELECT actor_sequence.nextval INTO :NEW.actor_id
FROM DUAL;
END IF;:NEW.last_update:=current_date;END;
故oracle-sakila-insert-data.sql的出入语句,如下所示,制定了actor_id,没有影响actor_sequence的nextval值。
Insert into actor (actor_id,first_name,last_name,last_update) Values ('','PENELOPE','GUINESS','2006-02-15 04:34:33.000');
现在根据验证的sql中记录条数+1 作为各个表主键自增sequence的nextval
SELECT 'ACTOR' AS TABLENAME, COUNT(*)+1 AS NEXTVAL FROM ACTOR UNION ALL
SELECT 'ADDRESS' , COUNT(*)+1 FROM ADDRESS UNION ALL
SELECT 'CATEGORY' , COUNT(*)+1 FROM CATEGORY UNION ALL
SELECT 'CITY' , COUNT(*)+1 FROM CITY UNION ALL
SELECT 'COUNTRY' , COUNT(*)+1 FROM COUNTRY UNION ALL
SELECT 'CUSTOMER' , COUNT(*)+1 FROM CUSTOMER UNION ALL
SELECT 'FILM' , COUNT(*)+1 FROM FILM UNION ALL
SELECT 'INVENTORY' , COUNT(*)+1 FROM INVENTORY UNION ALL
SELECT 'LANGUAGE' , COUNT(*)+1 FROM LANGUAGE UNION ALL
SELECT 'PAYMENT' , COUNT(*)+1 FROM PAYMENT UNION ALL
SELECT 'RENTAL' , COUNT(*)+1 FROM RENTAL UNION ALL
SELECT 'STAFF' , COUNT(*)+1 FROM STAFF UNION ALL
SELECT 'STORE' , COUNT(*)+1 FROM STORE
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAANcAAAE5CAIAAACMJiKkAAAbLklEQVR4nO2dzY7jNrbH+Ty9DAqGrEdIP0KADuB2C6mnyCKdCdrtSnmTfW6vOqsqF9C+mJlkNas7CBCgP7xoaTeYezHIZOA7nerqqjsT3YW+DslD6dAWJVE+fxCFMnVISuTPFCXw+IjdbpemaZqmT5bfvHv37qcB6Mnym3SQerL8pu+++emnn3569+7dk+U3Qxiv7EwO71ix2+2ySxpUOvzCXKj3bhlrEuVcyGL1JaaQ1b+YQlb/YgpZ/YspZPUvEoVJkvzlJuVkm5Ik6WAIByv65TOFTKErMYWDSEwh0ZIpZApdiSkcRGIKiZZMIVPoSq4ofDYTqmabotPjzyfwo2Y/Of8TsPzkEg5Y/PkEVho9qzKnn78GlpcRqAdtFCt1k/7lZvNJdQ5oc04pjM+nQojpeQy6dRMVGdnR6nw22VHJfhMJIaLNJtKGIMuMNnDI4vMpKB2fTxWD+HyqlGhfrufCzSf6yL0+/2gy/UjOfzYTHy3iisgcF5xCOafInMnYKRQijcafT8RHk2nZbpb+tJiC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Y+Zn5KZ4er5q/BQCHg6NTGsTB09auGkvZtB4jMb1Hzmenq8aP4XSgB32vpDj4DnSMVBYIzsKOQKZIzGFREum0KGYQqIlx8FzKKaQaMkRyByKKSRa/j+p3OUPl/oGjwAAAABJRU5ErkJggg==" alt="" />
/*
Navicat Oracle Data Transfer
Oracle Client Version : 12.1.0.1.0 Source Server : sakila
Source Server Version : 120100
Source Host : localhost:1521
Source Schema : SAKILA Target Server Type : ORACLE
Target Server Version : 120100
File Encoding : 65001 Date: 2015-04-19 02:35:56
*/ -- ----------------------------
-- Sequence structure for ACTOR_SEQUENCE
-- ----------------------------
DROP SEQUENCE "ACTOR_SEQUENCE";
CREATE SEQUENCE "ACTOR_SEQUENCE"
INCREMENT BY 1
MINVALUE 1
NOMAXVALUE
START WITH 201
CACHE 20; -- ----------------------------
-- Sequence structure for ADDRESS_SEQUENCE
-- ----------------------------
DROP SEQUENCE "ADDRESS_SEQUENCE";
CREATE SEQUENCE "ADDRESS_SEQUENCE"
INCREMENT BY 1
MINVALUE 1
NOMAXVALUE
START WITH 604
CACHE 20; -- ----------------------------
-- Sequence structure for CATEGORY_SEQUENCE
-- ----------------------------
DROP SEQUENCE "CATEGORY_SEQUENCE";
CREATE SEQUENCE "CATEGORY_SEQUENCE"
INCREMENT BY 1
MINVALUE 1
NOMAXVALUE
START WITH 17
CACHE 20; -- ----------------------------
-- Sequence structure for CITY_SEQUENCE
-- ----------------------------
DROP SEQUENCE "CITY_SEQUENCE";
CREATE SEQUENCE "CITY_SEQUENCE"
INCREMENT BY 1
MINVALUE 1
NOMAXVALUE
START WITH 601
CACHE 20; -- ----------------------------
-- Sequence structure for COUNTRY_SEQUENCE
-- ----------------------------
DROP SEQUENCE "COUNTRY_SEQUENCE";
CREATE SEQUENCE "COUNTRY_SEQUENCE"
INCREMENT BY 1
MINVALUE 1
NOMAXVALUE
START WITH 110
CACHE 20; -- ----------------------------
-- Sequence structure for CUSTOMER_SEQUENCE
-- ----------------------------
DROP SEQUENCE "CUSTOMER_SEQUENCE";
CREATE SEQUENCE "CUSTOMER_SEQUENCE"
INCREMENT BY 1
MINVALUE 1
NOMAXVALUE
START WITH 600
CACHE 20; -- ----------------------------
-- Sequence structure for FILM_SEQUENCE
-- ----------------------------
DROP SEQUENCE "FILM_SEQUENCE";
CREATE SEQUENCE "FILM_SEQUENCE"
INCREMENT BY 1
MINVALUE 1
NOMAXVALUE
START WITH 1001
CACHE 20; -- ----------------------------
-- Sequence structure for INVENTORY_SEQUENCE
-- ----------------------------
DROP SEQUENCE "INVENTORY_SEQUENCE";
CREATE SEQUENCE "INVENTORY_SEQUENCE"
INCREMENT BY 1
MINVALUE 1
NOMAXVALUE
START WITH 4582
CACHE 20; -- ----------------------------
-- Sequence structure for LANGUAGE_SEQUENCE
-- ----------------------------
DROP SEQUENCE "LANGUAGE_SEQUENCE";
CREATE SEQUENCE "LANGUAGE_SEQUENCE"
INCREMENT BY 1
MINVALUE 1
NOMAXVALUE
START WITH 7
CACHE 20; -- ----------------------------
-- Sequence structure for PAYMENT_SEQUENCE
-- ----------------------------
DROP SEQUENCE "PAYMENT_SEQUENCE";
CREATE SEQUENCE "PAYMENT_SEQUENCE"
INCREMENT BY 1
MINVALUE 1
NOMAXVALUE
START WITH 16050
CACHE 20; -- ----------------------------
-- Sequence structure for RENTAL_SEQUENCE
-- ----------------------------
DROP SEQUENCE "RENTAL_SEQUENCE";
CREATE SEQUENCE "RENTAL_SEQUENCE"
INCREMENT BY 1
MINVALUE 1
NOMAXVALUE
START WITH 16045
CACHE 20; -- ----------------------------
-- Sequence structure for STAFF_SEQUENCE
-- ----------------------------
DROP SEQUENCE "STAFF_SEQUENCE";
CREATE SEQUENCE "STAFF_SEQUENCE"
INCREMENT BY 1
MINVALUE 1
NOMAXVALUE
START WITH 3
CACHE 20; -- ----------------------------
-- Sequence structure for STORE_SEQUENCE
-- ----------------------------
DROP SEQUENCE "STORE_SEQUENCE";
CREATE SEQUENCE "STORE_SEQUENCE"
INCREMENT BY 1
MINVALUE 1
NOMAXVALUE
START WITH 3
CACHE 20;
也可以在图形化工具中直接改sequence的值。
现在的sakila数据库有了oracle实现,可以作为数据仓库、ODI ETL学习的源数据库了。
oracle-sakila-db sakila的Oracle版本的更多相关文章
-
oracle 19c dataguard silent install (oracle 19c dataguard 静默安装)
环境说明 1.关闭透明大页 RHEL 6: # cat /sys/kernel/mm/redhat_transparent_hugepage/enabled [oracle@rhel 6 ~]$ c ...
-
CentOS以及Oracle数据库发展历史及各版本新功能介绍, 便于构造环境时有个对应关系
CentOS版本历史 版本 CentOS版本号有两个部分,一个主要版本和一个次要版本,主要和次要版本号分别对应于RHEL的主要版本与更新包,CentOS采取从RHEL的源代码包来构建.例如CentOS ...
-
转 使用SwingBench 对Oracle RAC DB性能 压力测试
###########说明1: 1 Swingbench 简述 1.1 概述 这是Oracle UK的一个员工在一个被抛弃的项目的基础上开发的.目前稳定版本2.2,最新版本2.3,基于JDK1.5.该 ...
-
了解 Oracle Berkeley DB 可以为您的应用程序带来 NoSQL 优势的原因及方式。
将 Oracle Berkeley DB 用作 NoSQL 数据存储 作者:Shashank Tiwari 2011 年 2 月发布 “NoSQL”是在开发人员.架构师甚至技术经理中新流行的一个词汇. ...
-
Cannot create an instance of OLE DB provider ";OraOLEDB.Oracle"; for linked server ";xxxxxxx";.
在SQL SERVER 2008 R2下用Windows 身份认证的登录名创建了一个访问ORACLE数据库的链接服务器xxxxx,测试成功,木有问题,但是其它登录名使用该链接服务器时,报如下错误: 消 ...
-
【Oracle】ORACLE SQL Developer不支持JAVA版本
ORACLE SQL Developer不支持JAVA版本 今天我打开 ORACLE SQL Developer准备开始练手.没有想到却给出了错误提示. 我 是安装了java JDK的而且是1.6版本 ...
-
Oracle Berkeley DB Java 版
Oracle Berkeley DB Java 版是一个开源的.可嵌入的事务存储引擎,是完全用 Java 编写的.它充分利用 Java 环境来简化开发和部署.Oracle Berkeley DB Ja ...
-
Cannot create an instance of OLE DB provider “OraOLEDB.Oracle” for linked server ";xxxxxxx";.
在SQL SERVER 2008 R2下用Windows 身份认证的登录名创建了一个访问ORACLE数据库的链接服务器xxxxx,测试成功,木有问题,但是其它登录名使用该链接服务器时,报如下错误: 消 ...
-
Cannot obtain the required interface (";IID_IDBCreateCommand";) from OLE DB provider ";OraOLEDB.Oracle"; for linked server xxxx
今天遇到了一个关于LINKED SERVER查询报错的案例,链接服务器链接ORACLE数据库,测试没有错误,但是执行脚本的时候,报如下错误: Msg 7399, Level 16, State 1 ...
-
java.util.MissingResourceException: Can't find resource for bundle oracle.sysman.db.rsc.LoginResourc
http://blog.itpub.net/197458/viewspace-1055358/ oracle 10.2.0.4 windows 2003 X64 平台 系统安装EMCA正常.第一次 ...
随机推荐
-
安装oracle 11g时出现启动服务出现错误,找不到OracleMTSRecoveryService
运行注册表(cmd-输入regedit),到 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services下,找到OracleMTSRecoveryServ ...
-
C#命名空间的嵌套
namespace abc.e.f//等价于下面分层嵌套的写法.且这种写法不管命名空间abc有没有定义过,也不管命名空间e有没有定义过 { class ctest { public void func ...
-
跟着ttlsa一起学zabbix监控呗
本章转载至:http://www.ttlsa.com/zabbix/follow-ttlsa-to-study-zabbix/ 虽然接触zabbix时间很长,但是中间相当一段时间没去配置,这次算是重新 ...
-
express 查看版本号
新安装了express,但是当查看版本号输入: express -v 时出现如下错误: 网上查找了相关资料才发现express查看版本 的命令是 express -V (即V大写) 再次尝试: 发现同 ...
-
09-排序2 Insert or Merge
要点就是把排序每一步,判断一下是否和第二组数据相同,若相同则输出排序方法和下一次序列. According to Wikipedia: Insertion sort iterates, consumi ...
-
python(1) - 变量小测试
下面看一道题目: a = 3 b = a a = 5 print(a,b) 程序最后输出的a,b值分别是多少呢? 先想一想,然后我们执行一下看看正确答案: 正确答案 a 的值是5, b的值是3,为什么 ...
-
Android源码学习之装饰模式应用
首先得了解最基础的装饰器模式 参考 设计模式之八 --- 装饰模式(Decorator) 参考链接:http://blog.csdn.net/cjjky/article/details/7478788 ...
-
Linux如何配置想要的JDK
首先我声明下,对于linux系统我到现在学习不到一个星期,所以说很多地方不熟悉,还在学习当中,本文章中有什么技术错误请勿怪哈(PS:我第一次发表博客). 关于linux安装配置jdk,首先我用的是De ...
-
常见类 Object
1.在Java类继承结构中Java.lang.Object类位于顶端 2.如果定义一个Object类没有使用extends关键字声明其父类,则其父类为Java.lang.Object类 3.Objec ...
-
C#语法快速热身
if选择结构: 简单:if结构 单分子:If-else结构 多重:f-else-if结构 嵌套:if结构 语法: If(条件1){ If(条件2) }else{ } }else{ } Switch结构 ...