Dualo
SQL Essentials

What is SQL?

A declarative language for querying relational databases. You describe WHAT you want; the engine figures out HOW to get it.

1 min read

SQL (Structured Query Language) is the language you use to talk to a relational database. A relational DB stores data in tables — rows and columns, like a spreadsheet on steroids. Each row is one record; each column is one attribute.

Key property: SQL is . You write 'give me the 10 most recent orders for customer 42' — you don't write the loops or the index lookups. The database has an that figures out the best execution plan.

Contrast with imperative code (Python, JavaScript): imperative = step-by-step instructions. Declarative = goal statement. For data, declarative wins — you can change the physical storage (indexes, partitions) without rewriting a single query.

Five verbs cover 90% of daily work: SELECT (read), INSERT (write new row), UPDATE (modify existing), DELETE (remove), CREATE/ALTER/DROP (schema changes). The first four are (Data Manipulation Language); the others are DDL (Data Definition Language).

Most RDBMS share the SQL-92 core, then each dialect adds its own extensions: PostgreSQL (most feature-rich open-source), MySQL (most widely deployed), SQLite (embedded — in your phone, in your browser), SQL Server, Oracle. Learn core SQL; cross-train to dialect quirks when needed.

Grounded on https://www.postgresql.org/docs/current/sql.html

Next up

SELECT basics — filter, sort, limit

The bread and butter: SELECT columns FROM table WHERE conditions ORDER BY sort LIMIT n. Learn this well; everything else builds on it.