Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

PostgreSQL Tutorial

Overview

PostgreSQL is a full-featured, open-source relational database system. It is used for several tutorials and for the DATA605 class project in umd_classes.

In this tutorial you will:

Workflow

Set up environment

Build container (optional)

Run container

PostgreSQL

Start Postgres

Creating example databases

Creating the small university database

Creating the university_large database

Connecting to Postgres

MethodWhen to use
psql inside the containerQuickest for ad-hoc queries and setup
psql from your laptopDemonstrates the client-server model over a network port
Jupyter notebookRecommended for running the tutorial notebooks

Connecting from inside the container

Using a second terminal in the same container

Connecting from your laptop

Connecting from Jupyter notebook

Using psql CLI

Quick reference

CommandDescription
\hHelp on SQL command syntax
\?Help on psql backslash commands
\lList all databases
\c <db>Connect to a database
\dList tables in the current database
\d <table>Show schema for a table
\qQuit psql

Examples

Other notebook examples