DVD Rental Database
Source
https://github.com/syedjaferk/postgres_sample_database/blob/main/dvd_rental/dvdrental.tar
Steps to import the database
Download the tar file from the given link.
Create the dvdrental database. Login to the postgres db, with the user. (here for example we are using the postgres superuser.)
psql -U postgresAfter entering the password correctly, you will be connected to the PostgreSQL server.
postgres=#
Second, create a new database called dvdrental using CREATE DABASE statement:
CREATE DATABASE dvdrental;
Output:
CREATE DATABASEPostgreSQL will create a new database called dvdrental.
Third, verify the database creation using the \l command. The \l command will show all databases in the PostgreSQL server. The output shows that dvdrental on the list, meaning that you have created the dvdrental database successfully. Now disconnect from the PostgreSQL server and exit the psql using the exit command
Load the dataset into the db using the
pg_restore
pg_restore -U postgres -d dvdrental dvdrental.tarn this command:
The
-U postgresinstructspg_restoreto connect the PostgreSQL server using thepostgresuser.The
-d dvdrentalspecifies the target database to load.
It might prompt you to enter the password for the postgres user. Enter the password for the postgres user and press the Enter (or Return key)
It’ll take about seconds to load data stored in the dvdrental.tar file into the dvdrental database.
Verify the database is loaded.
Login to the postgres with database as dvdrental,
psql -U postgres -d dvdrental;
display all tables in the dvdrental database
\dt
Now you have the practice DB. Happy Learning !
Last updated