Get AI summaries of any video or article — Sign up free
SQL Tutorial for Beginners 1: Installing PostgreSQL and Creating Your First Database thumbnail

SQL Tutorial for Beginners 1: Installing PostgreSQL and Creating Your First Database

Corey Schafer·
4 min read

Based on Corey Schafer's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.

TL;DR

Postgres.app is the recommended macOS installation path because it runs a PostgreSQL server in the menu bar without a traditional installer.

Briefing

SQL’s value for beginners comes down to practicality: most software systems rely on databases, and SQL offers a relatively small set of core commands for common tasks like filtering and retrieving data. That makes it a strong on-ramp for computer science and programming careers, especially compared with learning a full programming language’s syntax and logic. With that motivation, the setup process focuses on getting a working PostgreSQL environment so SQL queries can be run immediately.

The tutorial walks through installing PostgreSQL on a Mac using the “Postgres.app,” a native macOS app that runs in the menu bar and avoids a traditional installer. After downloading and moving the app into the Applications folder, the PostgreSQL server starts and shows an elephant icon indicating it’s running on port 5432. The app also offers an option to open a command-line interface for issuing database commands.

To create a first database, the tutorial uses the command-line tool with a simple SQL statement: `create database sample_db;` (ending the command with a semicolon). It then verifies the new database by listing databases with `\\l`, confirming that `sample_db` now exists alongside the default databases created during installation. Exiting the command line is done with `\\q`.

Because command-line output can be harder to visualize, the tutorial adds a graphical interface: “pgAdmin” is not used here; instead it installs “PSequel,” chosen for a clean layout and the ability to enlarge fonts—useful for recording and readability. After installing and launching PSequel, a macOS security prompt may appear (“developer cannot be confirmed”); the workaround is to right-click and choose “Open” to proceed.

With PSequel running, the connection settings largely follow defaults, including port 5432, which must match the PostgreSQL server’s port. The key change is selecting the database name created earlier: `sample_db`. Once connected, the database initially appears empty because no tables exist yet.

From there, the tutorial demonstrates the next step conceptually: creating a table (named `test_table`) and adding at least one column (column `a`). After running the table-creation SQL and refreshing the table list in the interface, the new table appears with the expected column structure. The takeaway is a complete starter workflow—install PostgreSQL, create a database, connect through a GUI, and run SQL to create tables—setting up the next tutorial to focus on adding tables and writing more detailed SQL commands.

Cornell Notes

SQL is positioned as a practical entry point because most software relies on databases and SQL’s core commands cover common tasks like retrieving and filtering data. The setup uses PostgreSQL on macOS via Postgres.app, which runs in the menu bar and listens on port 5432. A first database is created from the command line with `create database sample_db;`, then verified using `\l`. For easier inspection, PSequel is installed as a GUI client; it connects to PostgreSQL using port 5432 and the `sample_db` database. After connecting, the database is empty until a table is created (e.g., `test_table` with column `a`), after which the table appears in the interface.

Why does the tutorial recommend SQL as a beginner-friendly skill, and what kinds of tasks does it emphasize?

SQL is framed as valuable because nearly every software system interacts with a database. The tutorial emphasizes that beginners can quickly learn a limited set of commands that handle common job tasks—especially grabbing values that match criteria—before moving on to more advanced queries later.

What is the simplest way shown to install PostgreSQL on a Mac, and what does it provide immediately?

The tutorial uses Postgres.app, a native macOS app that runs in the menu bar without a traditional installer. Once installed, it starts a PostgreSQL server that can be accessed on port 5432 and provides an option to open a command-line interface for running SQL commands.

How is the first database created and confirmed in the command line?

The database is created with `create database sample_db;` (including a semicolon). It is confirmed by listing databases using `\l`, where `sample_db` appears alongside the default databases created during installation.

Why add a GUI tool like PSequel, and what connection details must match PostgreSQL?

A GUI helps visualize database contents instead of relying on command-line output. PSequel is chosen for a clean interface and readable, enlargeable fonts. Connection settings must match the PostgreSQL server—especially port 5432—and the database name must be set to `sample_db`.

What happens after connecting to `sample_db`, and how does the tutorial demonstrate the next step?

After connecting, the database appears empty because no tables exist yet. The tutorial then creates a table (named `test_table`) with a basic column (column `a`), refreshes the table list, and shows the new table and column appearing in the GUI.

Review Questions

  1. What exact command is used to create the initial database, and why is the semicolon important?
  2. Which port must the GUI client use to connect to PostgreSQL in this setup, and how is that port identified?
  3. After connecting to `sample_db`, what must be created before any tables appear in the GUI?

Key Points

  1. 1

    Postgres.app is the recommended macOS installation path because it runs a PostgreSQL server in the menu bar without a traditional installer.

  2. 2

    The PostgreSQL server runs on port 5432, and clients must use the same port to connect successfully.

  3. 3

    A first database is created with `create database sample_db;` and verified using `\l`.

  4. 4

    PSequel is used as a GUI client to inspect databases and tables more easily than command-line output.

  5. 5

    macOS may block launching PSequel with a “developer cannot be confirmed” warning; right-clicking and choosing “Open” bypasses it.

  6. 6

    After connecting to `sample_db`, the database is empty until SQL creates tables such as `test_table` with column `a`.

  7. 7

    Refreshing the GUI’s table list confirms that table-creation SQL executed correctly.

Highlights

Postgres.app starts PostgreSQL on port 5432 and provides a quick path to run SQL commands.
Creating `sample_db` is a one-liner: `create database sample_db;`, followed by `\l` to confirm it exists.
PSequel’s connection settings must align with the server’s port 5432 and the database name `sample_db`.
Once connected, the database shows no tables until a `create table` command adds structure like `test_table` with column `a`.
The setup sequence—install server, create database, connect via GUI, create a table—forms a complete SQL starter workflow.

Topics

  • SQL Setup
  • PostgreSQL Installation
  • Database Creation
  • PSequel Connection
  • Creating Tables

Mentioned

  • Postgres.app
  • PSequel