Summary: in this tutorial, we will show you how to load the PostgreSQL sample database into the PostgreSQL database server.
Before going forward with this tutorial, you must have:
- PostgreSQL database server installed on your system. If you don’t have, you can follow the step-by-step installing PostgreSQL tutorial.
- The DVD Rental database available.
Creating a new DVD rental database
You need to create a new database in the PostgreSQL database server before loading database schema and data into the database.
First, launch the psql tool.

Second, enter the account’s information to log in to the PostgreSQL database server. You can use the default value provided by psql by pressing Enter keyboard. However, for the password, you need to enter the one that you provided during PostgreSQL installation.
1 2 3 4 5 | Server [localhost]: Database [postgres]: Port [5432]: Username [postgres]: Password for user postgres: |
Third, enter the following CREATE DATABASE statement to create a new dvdrental database.
1 | CREATE DATABASE dvdrental; |
PostgreSQL will create a new database named dvdrental.
Load the DVD rental database using psql tool
First, unzip and copy the DVD rental database file to a folder e.g., c:\dvdrental\dvdrental.tar
Next, launch the Command Prompt program by using the keyboard shortcut Windows + R, type cmd, and press Enter:

The Command prompt will look like this:

Then, navigate the bin folder of the PostgreSQL installation folder:
1 | C:\>cd C:\Program Files\PostgreSQL\11\bin |
After that, use the pg_restore tool to load data into the dvdrental database:

1 | pg_restore -U postgres -d dvdrental C:\dvdrental\dvdrental.tar |
In this command:
- The
-U postgresspecifies thepostgresuser to login to the PostgreSQL database server. - The
-d dvdrentalspecifies the target database to load.
Finally, enter the password for the postgres user and press enter
1 | Password: |
It takes seconds to load data stored in the dvdrental.tar file into the dvdrentaldatabase.
Load the DVD Rental database using the pgAdmin
You can use the pgAdmin tool to restore the sample database from the downloaded database file using the following steps:
First, launch the pgAdmin tool and connect to the PostgreSQL server.
Next, right-click on the dvdrental database and choose Restore… menu item as shown in the following picture:

Then, provide the path to database file e.g., c:\dvdrental\dvdrental.tar and click the Restore button

After that, wait for a few seconds to let the restoration process completes.
Finally, open the dvdrental database from object browser panel, you will see the tables in the public schema and other database objects as shown in the following picture:

We have shown you how to load the dvdrental sample database into the PostgreSQL database server for learning and practicing PostgreSQL.
Let’s start learning PostgreSQL and have fun!