EXDvRQz7REOw70UM-4RDMg Course1PostgreSQLpgAdminTutorial
EXDvRQz7REOw70UM-4RDMg Course1PostgreSQLpgAdminTutorial
This document provides important details about using PostgreSQL in this course.
standard. Many organizations use PostgreSQL in major information systems. This tutorial
software to execute SQL statements. This tutorial initially uses the latest stable versions of
1. Installation
You can download various versions of PostgreSQL from the organization’s website
Select the appropriate operating system to start the download process. This tutorial demonstrates
the installation of PostgreSQL for Windows 11 so Windows was selected. The Windows
Installers page (Figure 3) shows the PostgreSQL versions supported on Windows 11.
Click the Download the Installer link to open the EDB page for Windows PostgreSQL
installers (Figure 4), then select the version to download. In this tutorial, select Windows x86-
64. The installer should be begun downloading. Keep the installation file if asked (Figure 5)
After downloading completes, you can start the installation by double clicking the .exe
file (postgresql-14.4-1-windows-x64.exe in this tutorial). Let the installer take control (respond
yes) to begin installation. Select Next > for the first installation window (Figure 6). In the next
window, choose the installation folder (Figure 7). Follow the remaining installation windows
(Figures 8 to 16) to complete the installation. In the Password window (Figure 9), you must
enter a password for the superuser (postgres). You must remember this password as you will
need to use the password when starting PostgreSQL. After the last installation window (Figure
15), you can skip the Stack Builder additional installation by clicking the Cancel button (Figure
16). You can use Stack Builder later if you want to install other components.
8/1/24 Tutorial for PostgreSQL and pgAdmin 5
Note: The port number will be needed to create connections to PostgreSQL server. You should
remember this for later usages.
8/1/24 Tutorial for PostgreSQL and pgAdmin 11
Figure 15: Completing the PostgreSQL Setup Wizard. (You can uncheck here)
8/1/24 Tutorial for PostgreSQL and pgAdmin 16
databases. Start pgAdmin by typing pgAdmin in search box and click on pgAdmin in the result
(Figure 17) or browse to pgAdmin in PostgreSQL 14 folder and click on it (Figure 18)
8/1/24 Tutorial for PostgreSQL and pgAdmin 17
Figure 17: Search and Select pgAdmin from Window Start Search Box
8/1/24 Tutorial for PostgreSQL and pgAdmin 18
You can create a short cut to pgAdmin by dragging the pgAdmin icon to the desktop, so
you can quickly open it later. Starting pgAdmin window will appear when you click on
pgAdmin.
8/1/24 Tutorial for PostgreSQL and pgAdmin 19
After pgAdmin begins, you need to enter the master password that you provided in the
installation process (Figure 20). After entering the password, pgAdmin opens with the Servers
object without expansion (Figure 21). After you expand the Servers object, you need to provide
the master password again (Figure 22). You can check save so that you do not need to enter
password for later access. After the Servers object expands, you can expand the Databases object
server, the latest version in July 2022. pgAdmin 4 seems to work identically with PostgreSQL 12
Although you can use the default postgres database to execute SQL statements, I
recommend creating separate databases for each database used in the course. With separate
databases, you will not have conflicts among common table names in the course databases.
Follow these steps to create a new database for the university database tables and then connect to
the new database so that you can enter SQL statements to create and populate tables.
8/1/24 Tutorial for PostgreSQL and pgAdmin 23
Right click on the Databases (1) object inside the PostgreSQL 14 object (Figure 24).
Enter the database name (UnivDB) and click the Save button (Figure 25). The
window will be closed, and you will see the notification to show the database was
Expand the Databases object to see the StoreSales database (Figure 27).
Query Tool for each database in which you want to execute SQL statements. Follow these steps
to create and populate the university database tables. For other databases, you can create the
database as described in the previous section and the use the Query Tool to execute SQL
statements.
8/1/24 Tutorial for PostgreSQL and pgAdmin 27
Expand the UnivDB object (Figure 28). The click the Query Tool ( ) to open the
Query Window for the UnivDB database. Alternatively, you can right click on the
The Query Window opens showing a new panel (top right) for the UnivDB database
(Figure 29). Make sure the database name (in red boxes) is correct
Copy and paste the CREATE statements for the University Database. You can find
these statements in Module 2 Lecture Notes page. Click the Run button ( ) to
Use the Clear Query (Figure 31) in Edit menu . Respond Yes to the prompt
about discarding the current changes in the Query Window (Figure 32)
Copy and paste the INSERT statements for the University Database. You can find
these statements in the Module 3 Lecture Notes. Click the Run button to execute the
Expand the Tables object (Figure 34) to see the list of tables created.
You can count the rows to verify the execution of the INSERT statements. Right
click the Student table and select Count Rows (Figure 35).
8/1/24 Tutorial for PostgreSQL and pgAdmin 28
Figure 30: Query Editor Window with Executed SQL Statements to Create Tables
Figure 33: Query Editor Window with Executed SQL Statements to Populate Tables
8/1/24 Tutorial for PostgreSQL and pgAdmin 31
assignments. To use pgAdmin, you should open pgAdmin, expand the database that you
previously created, and open the Query Tool for the database to execute SQL statements. If you
have not created the database used in the assignment, lecture class, or lab class, you should
follow the steps to create and populate a new database before executing SQL statements for the