Last Updated : 20 Sep, 2021
In this article we will look into the process of loading a PostgreSQL database into the PostgreSQL database server.
Before moving forward we just need to make sure of two things:
For the purpose of this article, we will be using a sample database which is DVD rental database.
You can download the sample dvdrental database from here.
So, the DVD rental database that we will be using ahead in the article represents a DVD rental store. The objects in the database includes:
ER Model of the sample Database:
Tables in the Sample Database:
There are 15 tables in our sample database which are listed below:
So now we know everything about our sample DVD rental database, let us move on to loading the same database to the PostgreSQL database server. The steps to which are listed below:
Server [localhost]: Database [postgres]: Port [5432]: Username [postgres]: Password for user postgres:
Now using the CREATE DATABASE statement create a new database as follows:
CREATE DATABASE dvdrental;
Use the pg_restore tool to load data into the dvdrental database that we had just created as using the command:
pg_restore -U postgres -d dvdrental C:\users\sample_datbase\dvdrental.tar
It would somewhat look like below:
Now enter your database user Password and your sample database will be loaded.
Verify Database Load:Now if you need to verify if the sample database is loaded, use the below command to get into the database in SQL shell:
\c
Now to list all the tables in the database, use the below command:
\dt
The result should look like below:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4