Lab B - Installation and Test of Sakila Database
Lab B - Installation and Test of Sakila Database
https://dev.mysql.com/doc/index-other.html
Page 1 of 12
COURSE: MySQL Server Administration
LAB B – INSTALLATION AND TEST OF SAKILA DATABASE
-Move the cursor behind the page and click on “Sakila database Zip distribution”.
-You will see that the package download to your Windows Server Node.
Page 2 of 12
COURSE: MySQL Server Administration
LAB B – INSTALLATION AND TEST OF SAKILA DATABASE
-Right Click over the zip file and Extract All the installation archive to a temporary location, when you
unpack the archive, it creates a directory named sakila-db that contains the sakila-schema.sql and sakila-
data.sql files.
Page 3 of 12
COURSE: MySQL Server Administration
LAB B – INSTALLATION AND TEST OF SAKILA DATABASE
Page 4 of 12
COURSE: MySQL Server Administration
LAB B – INSTALLATION AND TEST OF SAKILA DATABASE
IMPORTANT:
The sakila-schema.sql file contains all the CREATE statements required to create the structure of the
Sakila database including tables, views, stored procedures, and triggers.
The sakila-data.sql file contains the INSERT statements required to populate the structure created by
the sakila-schema.sql file, along with definitions for triggers that must be created after the initial data
load.
The sakila.mwb file is a MySQL Workbench data model that you can open within MySQL Workbench to
examine the database structure. For more information, see MySQL Workbench.
-Connect to the MySQL server using the Windows Server command-line session with the following
command: mysql -u root -p
Page 5 of 12
COURSE: MySQL Server Administration
LAB B – INSTALLATION AND TEST OF SAKILA DATABASE
-Then you will run the script to create an Schema, type the command and Press Enter:
SOURCE E:\sakila-db\sakila-schema.sql
-You will see a very Rows affected and Database Changed Message.
-Then you will run the script to create the data in Database, type the command and Press Enter:
SOURCE E:\sakila-db\sakila-data.sql
Page 6 of 12
COURSE: MySQL Server Administration
LAB B – INSTALLATION AND TEST OF SAKILA DATABASE
-You will see a very Rows affected and Database Changed Message.
USE sakila
Page 7 of 12
COURSE: MySQL Server Administration
LAB B – INSTALLATION AND TEST OF SAKILA DATABASE
--You will SHOW tables of the new Database, type the Command and Press Enter:
SHOW TABLES
Page 8 of 12
COURSE: MySQL Server Administration
LAB B – INSTALLATION AND TEST OF SAKILA DATABASE
-Review the Row in Set value about Address Table, Type the command and Press Enter:
-Review the content of Address Table, Type the command and Press Enter:
Page 9 of 12
COURSE: MySQL Server Administration
LAB B – INSTALLATION AND TEST OF SAKILA DATABASE
-Review the Specific value inside the Address Table, Type the command and Press Enter:
You will see only the values for a register with address_id=500.
-Insert a new row set into rental Table, Type the next Command and press Enter:
INSERT INTO rental(rental_date, inventory_id, customer_id, staff_id) VALUES(NOW(), 10, 3, 1);
-Then Check the value (review the Date of NOW 2019), Type the next Command and press Enter:
SELECT * FROM rental WHERE inventory_id=10;
Page 10 of 12
COURSE: MySQL Server Administration
LAB B – INSTALLATION AND TEST OF SAKILA DATABASE
-Use a process inside Database to calculate the Balance for a customer, Type the next command and
press Enter:
SELECT @balance:=get_customer_balance(3,NOW());
-Now change a row set with this value calculate in the @balance, Type the next Command and Press
Enter:
INSERT INTO payment (customer_id, staff_id, rental_id, amount, payment_date)
VALUES(3,1,LAST_INSERT_ID(), @balance, NOW());
Page 11 of 12
COURSE: MySQL Server Administration
LAB B – INSTALLATION AND TEST OF SAKILA DATABASE
Task 4: Discussion.
1. What is the command you use to Select a Database?
4. What is the Link that you can use for download DataBase Examples for MySQL?
Page 12 of 12