FB

Sample Data for SQL Databases

Are you looking for some sample data sets to practice your SQL?

If so, you’re in the right place.

This page contains:

  • Several different data sets that you can download and use on your own database
  • SQL script files to create the tables and load the data, with different sets of scripts for Oracle, SQL Server, MySQL, and Postgres
  • An explanation of each data set with links to a more detailed explanation and an ERD
  • Steps on how to download the files, how to load the data, and what to do if you have any issues

Movies

A database of movies, cast and crew, production information, genres, and more.

Sample Database ERD and Explanation

SQL Scripts on GitHub

Video Games

A database of video games and their sales over time.

Sample Database ERD and Explanation

SQL Scripts on GitHub

Olympic Games

A database of Olympic games, competitors, events, and results.

Sample Database ERD and Explanation

SQL Scripts on GitHub

Superheroes

A database of superheroes from several sources, their powers, and their attributes.

Sample Database ERD and Explanation

SQL Scripts on GitHub

University Rankings

A small database that includes a list of universities in many countries, different ranking systems, and how each university ranks in those systems.

Sample Database ERD and Explanation

SQL Scripts on GitHub

Gravity Bookstore

A database for a fictional bookstore called “gravity” that captures information about books, customers, and sales.

Sample Database ERD and Explanation

SQL Scripts on GitHub

How to Download Scripts from GitHub

To download the scripts from GitHub for your own use, you can either download them individually from the website, or use Git commands.

Here are the steps to download them manually:

  1. Click on the SQL Scripts link for the data set above that you want to download.
  2. On the GitHub page that is displayed, open the folder for the database vendor you’re working with (e.g. MySQL).
  3. Click on the SQL file in the list to open it in GitHub
  4. Click on the Raw button on the top right to view the SQL file
  5. Right-click on the page and select Save As
  6. Save the SQL file to your computer

Repeat steps 3-6 above with all of the SQL files you need to download.

Coming soon: a guide on using Git commands to download the scripts (which I imagine will be easier than downloading them manually!)

How to Load the Data

All of the SQL scripts include the Create Table statements and Insert statements to add the data to the tables.

To load the sample data into your database, you will need:

  • An IDE (MySQL Workbench, SSMS, SQL Developer, etc)
  • A database (e.g. MySQL, SQL Server Express, Oracle Express, Postgres)

I’ll link to the How To Guides for setting these up when they are created.

Assuming you have an IDE and a database, you can load the data by:

  1. Open each of the scripts for the data set
  2. Run them in numerical order: run the script starting with 01 first, then the script starting with 02, and so on.

If there are any errors when running the scripts, you should be able to rerun only that file to drop and create the tables again.

Having Issues?

Are you getting an error when running the script?

Is there a syntax error or some other error in the script?

If so, they can be easily updated. Because the scripts are on GitHub, there are a few ways.

You could:

  • Create an Issue on the GitHub repository describing the issue and error, and the script name that is impacted. I can investigate and fix the file.
  • Or, if you know the fix and want to fix it yourself, create and submit a Pull Request for the file.
  • Or, you can fill out my Contact Form  here which will send me an email.

Coming soon: a how-to guide on creating a Pull Request to request an update to these files.

Submit a PR on the file if you want to change it – full how to coming soon

Or use the contact form

Or raise an issue on GItHub repo