MySQL Sample Database
This page demonstrates how to download and install a sample database — the Sakila sample database.
Why Install a Sample Database?
You can use a sample database to experiment with, without being concerned about accidentally deleting the wrong data or dropping the wrong tables, etc. If this happens, you can always re-install the DB (just run two scripts).
Also, one of the hardest things when developing your skills with databases is finding a database that contains enough data. So far we've used a very small database for our examples. That works fine for simple examples, but it can become quite limiting if you want to try out queries on a larger set of data.
The more complex your queries become, the more they will narrow the data down further. This is a crucial part of SQL programming. If your queries become complex, but you still only have a handful of records in the database, all your queries are going to return zero results!
Furthermore, if you only have two tables in your database, you can't really stretch out with more advanced queries.
This is when you need a larger database.
About the Sakila Sample Database
The Sakila sample database was created for the purposes of tutorials, books, examples, etc. It's also designed to take advantage of the various aspects of MySQL, including any new features.
Download the Sakila Database
First of all, download the Sakila database from the MySQL website.
This will give you two scripts to run (compressed into a Zip or TGZ file).
Install the Sakila Database
You install the database by running the two SQL scripts (one for the DB structure, one for the data).
Extract the Scripts
Extract the two SQL scripts from the ZIP or TGZ file (they should be called sakila-schema.sql and sakila-data.sql)
Open the Scripts
Execute the script
Repeat for the other Script
Now do the same with the other script (sakila-data.sql)
The SCHEMAS tab
Run a Query
Go ahead, use this database to experiment with. Select, delete, drop, create… it doesn't matter — you can always restore the DB at any time using the method above. Just run the two scripts. Simple!
If you're looking ideas on creating different queries, my SQL tutorial includes a few that we didn't cover here. In particular, you should be able to have some fun with SQL Joins when selecting data, and you could always try altering a table. After all, you can restore the DB as often as you like. Have fun!