Contents
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
- Go to postgresql.org/download and pick your operating system.
- Run the installer and keep the default options.
- When prompted, set a password for the default postgres user and write it down. You will need it every time you connect.
- 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 |
| DDL | Builds and changes table structure | CREATE, ALTER, DROP, TRUNCATE |
| DML | Changes the data inside tables | INSERT, UPDATE, DELETE |
| DQL | Reads data | SELECT |
| DCL | Controls who has access | GRANT, REVOKE |
| TCL | Saves or undoes a batch of changes | COMMIT, 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
Abhishek Pati








