Menu

How to Set Up PostgreSQL and Understand SQL Commands

How to Set Up PostgreSQL and Understand SQL Commands

SQL is the language you use to talk to a database, and a database is where an organization keeps its data in an organized form. To practice, you need one running on your own computer. PostgreSQL is free, works on Windows, macOS and Linux, and is the one this handbook uses.

Almost everything you learn here carries over to MySQL and other databases. Where PostgreSQL behaves differently, a short note will point it out.

Installing PostgreSQL

  1. Go to postgresql.org/download and pick your operating system.
  2. Run the installer and keep the default options.
  3. When prompted, set a password for the default postgres user and write it down. You will need it every time you connect.
  4. Leave the port at 5432 and let the installer add pgAdmin, a visual tool for running queries.

On Ubuntu, sudo apt install postgresql does the same job from the terminal.

Once it is installed, open pgAdmin, log in with your password, and open a query window. That window is where every example in this handbook will run.

The Groups of SQL Commands

SQL commands are sorted into groups based on what they do. You will see these names in documentation and interviews, so it helps to know them early.

Group

What It Does

Commands

DDLBuilds and changes table structureCREATE, ALTER, DROP, TRUNCATE
DMLChanges the data inside tablesINSERT, UPDATE, DELETE
DQLReads dataSELECT
DCLControls who has accessGRANT, REVOKE
TCLSaves or undoes a batch of changesCOMMIT, ROLLBACK

In data science work, most of what you write is SELECT. The DDL and DML commands come in when you build your own working tables, which is what the next two lessons cover.


SQL for Data Science

AP

Abhishek Pati



Learn via Video Course

Data Analysis and Processing with Python using Pandas - Data Science Course Logo

Data Analysis and Processing with Python using Pandas - Data Science Course

5 hrs



Get in Touch For Details