The Sakila sample database is available from http://dev.mysql.com/doc/index-other.html.
A downloadable archive is available in compressed tar file or Zip
format. The archive contains three files:
The
The
The
sakila-schema.sql
,
sakila-data.sql
, and sakila.mwb
. 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.
To install the Sakila sample
database, follow these steps:
- Extract the installation archive to a temporary location such as C:\temp\ or /tmp/. When you unpack the archive, it creates a directory named sakila-db that contains the sakila-schema.sql and sakila-data.sql files.
- Connect to the MySQL server using the mysql command-line client with the following command:
- shell> mysql -u root -p
Enter your
password when prompted. A non-root account can be used as long as the account has privileges
to create new databases.
- Execute the sakila-schema.sql script to create the database structure by using the following command:
- mysql> SOURCE C:/temp/sakila-db/sakila-schema.sql;
Replace C:/temp/sakila-db with the path to the sakila-schema.sql file on your system.
· Execute the sakila-data.sql script to populate the database structure with the
following command:
mysql>
SOURCE C:/temp/sakila-db/sakila-data.sql;
Replace C:/temp/sakila-db with the path to the sakila-data.sql file on your system.
· Confirm that the sample database is installed
correctly. Execute the following statements. You should see output similar to
that shown here.
mysql>
USE sakila;
Database
changed
mysql>
SHOW TABLES;
+----------------------------+
|
Tables_in_sakila |
+----------------------------+
|
actor |
|
address |
|
category |
|
city |
|
country |
|
customer |
|
customer_list |
|
film |
|
film_actor |
|
film_category |
|
film_list |
|
film_text |
|
inventory |
|
language |
|
nicer_but_slower_film_list |
|
payment |
|
rental |
|
sales_by_film_category |
|
sales_by_store |
|
staff |
|
staff_list |
|
store |
+----------------------------+
22
rows in set (0.00 sec)
mysql>
SELECT COUNT(*) FROM film;
+----------+
|
COUNT(*) |
+----------+
|
1000 |
+----------+
1
row in set (0.02 sec)
mysql>
SELECT COUNT(*) FROM film_text;
+----------+
|
COUNT(*) |
+----------+
|
1000 |
+----------+
1
row in set (0.00 sec)