Menu

Install the Sakila Sample Database in PostgreSQL

Step-by-step tutorial on downloading and installing the Sakila sample database in PostgreSQL using psql and pgAdmin 4.

The Sakila sample database is one of the most widely used and well-designed relational sample databases available. It models a DVD rental business, featuring tables for films, actors, categories, customers, rentals, and payments, along with a central inventory schema connecting stores and customers.

Originally developed for MySQL, Sakila has been ported to many database engines, including PostgreSQL. Throughout our PostgreSQL tutorial series, we use the Sakila sample database for query examples, indexing demonstrations, and administrative tasks.

In this guide, you will learn how to download and install the Sakila database on your PostgreSQL server using both psql and pgAdmin 4.

Prerequisites

Before installing the database, ensure you have:

  • A running PostgreSQL server (see our guide to installing PostgreSQL).
  • Downloaded the PostgreSQL port of the Sakila SQL scripts:
    • Visit the official repository: postgres-sakila-db on GitHub.
    • Download postgres-sakila-schema.sql (creates tables, views, sequences, triggers, and procedures).
    • Download postgres-sakila-insert-data.sql (inserts the sample dataset).

Save both files to a known local directory (e.g. C:/temp/ on Windows or ~/Downloads/ on macOS/Linux).

Method 1: Installing via the psql Command-Line Tool

The psql command-line utility provides the fastest and most scriptable way to import the database.

1. Connect to PostgreSQL and Create the Database

Open your terminal or PowerShell and connect to PostgreSQL as a superuser (such as postgres):

psql -U postgres

Enter your password when prompted, then create the sakila database:

CREATE DATABASE sakila;

2. Connect to the sakila Database

Switch your active connection to the newly created database:

\c sakila

3. Execute the SQL Scripts

Use the \i command to execute the schema script followed by the data insertion script. Use forward slashes (/) even on Windows:

\i /path/to/postgres-sakila-schema.sql
\i /path/to/postgres-sakila-insert-data.sql

PostgreSQL will process the statements, creating all tables and loading the records.

4. Verify the Installation

List the tables in the public schema using \dt:

\dt

Output:

            List of relations
 Schema |       Name       |  Type |  Owner
--------+------------------+-------+----------
 public | actor            | table | postgres
 public | address          | table | postgres
 public | category         | table | postgres
 public | city             | table | postgres
 public | country          | table | postgres
 public | customer         | table | postgres
 public | film             | table | postgres
 public | film_actor       | table | postgres
 public | film_category    | table | postgres
 public | inventory        | table | postgres
 public | language         | table | postgres
 public | payment          | table | postgres
 public | payment_p2007_01 | table | postgres
 public | payment_p2007_02 | table | postgres
 public | payment_p2007_03 | table | postgres
 public | payment_p2007_04 | table | postgres
 public | payment_p2007_05 | table | postgres
 public | payment_p2007_06 | table | postgres
 public | rental           | table | postgres
 public | staff            | table | postgres
 public | store            | table | postgres
(21 rows)

You are now ready to execute queries against the Sakila dataset!

Method 2: Installing via pgAdmin 4

If you prefer a graphical user interface, you can import Sakila using pgAdmin 4:

  1. Launch pgAdmin 4 and connect to your PostgreSQL server.
  2. In the left browser tree, right-click Databases and select Create > Database….
  3. In the dialog, set the database name to sakila and click Save.
  4. Right-click the new sakila database and choose Query Tool.
  5. Click the Open File icon in the toolbar, select postgres-sakila-schema.sql, and click Execute (or press F5).
  6. Next, open postgres-sakila-insert-data.sql in the Query Tool and click Execute. This loads the sample records into the schema.
  7. In the left navigation pane, expand sakila > Schemas > public > Tables to confirm that all 21 tables are present.

Sakila Database Schema Overview

The Sakila database contains 16 core tables, 7 views, stored procedures, functions, and triggers modeling an end-to-end retail business:

  • actor: Actor details (first name, last name).
  • address: Physical addresses for customers, staff, and stores.
  • category: Movie categories and genres.
  • city and country: Geographical references.
  • customer: Customer profile and membership status.
  • film: Comprehensive movie metadata (title, rental rate, duration, rating).
  • film_actor & film_category: Many-to-many junction tables.
  • inventory: Individual physical movie discs held across store locations.
  • language: Spoken languages for audio and subtitles.
  • payment: Financial transaction records.
  • rental: Checkout and return timelines for rentals.
  • staff: Store employees and managers.
  • store: Physical retail store locations.

Conclusion

With the Sakila sample database installed on PostgreSQL, you have a realistic, production-like dataset for practicing SQL queries, mastering joins, designing indexes, and testing performance. Check out our PostgreSQL Basics tutorials to start exploring queries.