SQL
Master SQL from scratch — 67 lessons covering queries, joins, optimisation, and advanced database engineering.
A complete SQL course — SELECT queries, joins, aggregation, indexing, views and stored procedures — with interactive beginner-friendly lessons.
Part of the free SQL course at LearnCodingFast — hands-on lessons with examples you run in your browser, plus practice exercises and a quick quiz.
👋 New to SQL? It's essential for every developer.
SQL is how you talk to databases. Start with Lesson 1 — you'll be writing real queries in minutes.
Lessons in this course
- Introduction to SQL — What SQL is, what databases are, and why you need to learn SQL
- Database Basics & Tables — Create databases and tables, understand rows, columns, and data types
- SELECT Statement — Retrieve data from tables with SELECT — the most important SQL statement
- WHERE Clause & Filtering — Filter rows by conditions using WHERE, AND, OR, and comparison operators
- ORDER BY & Sorting — Sort query results in ascending or descending order with ORDER BY
- SELECT DISTINCT — Remove duplicate rows from your results
- LIMIT, OFFSET, TOP & FETCH — Return only the first N rows — and paginate results
- Column & Table Aliases (AS) — Rename columns and tables in your queries for clarity
- LIKE & Wildcards — Match text patterns with LIKE, % and _
- IN, BETWEEN & Logical Operators — Filter with IN, BETWEEN, AND, OR and NOT
- CASE Expressions — Add if/then conditional logic to your queries
- NULL Handling (COALESCE, IS NULL) — Work with NULLs safely — COALESCE, IS NULL, and the = NULL trap
- Checkpoint: Querying Data — Combine the query clauses in a challenge — then a quiz
- String Functions — CONCAT, SUBSTRING, REPLACE, TRIM, UPPER/LOWER
- Date & Time Functions — Work with dates — DATEADD, DATEDIFF, EXTRACT, NOW
- CAST & CONVERT — Convert between data types in your queries
- The HAVING Clause — Filter grouped results — WHERE for groups
- UNION, INTERSECT & EXCEPT — Combine the results of multiple queries
- CREATE TABLE & Data Types — Create tables and choose the right column data types
- ALTER TABLE — Add, drop and modify columns on existing tables
- Constraints (PK, FK, UNIQUE, CHECK) — Enforce data integrity with primary/foreign keys and constraints
- DROP vs TRUNCATE vs DELETE — The three ways to remove data — and when to use each
- Checkpoint: Building a Schema — Design a normalized schema with constraints — then a quiz
- JOIN Operations — Combine data from multiple tables using INNER, LEFT, RIGHT, and FULL JOINs
- Aggregate Functions — Calculate totals, averages, and counts with SUM, AVG, COUNT, MIN, MAX
- GROUP BY & HAVING — Group results and filter groups with GROUP BY and HAVING
- Subqueries — Nest queries inside other queries for complex data retrieval
- INSERT, UPDATE, DELETE — Add, change, and remove data in your database tables
- Indexes & Performance — Speed up queries dramatically by creating the right indexes
- Views & Stored Procedures — Create reusable views and stored procedures for complex query logic
- Transactions & ACID — Ensure data integrity with transactions, rollbacks, and ACID guarantees
- Advanced Queries — CTEs, window functions, and advanced SQL patterns for real-world data
- Advanced Relational Database Theory & Normalization (BCNF, 4NF, 5NF) — Eliminate data anomalies with higher normal forms beyond 3NF
- Indexing Internals: B-Trees, Hash Indexes, Bitmap Indexes & When to Use Them — Understand index data structures and choose the right index for each query
- Query Optimization Deep Dive: Execution Plans, Cost Estimation & Hints — Read EXPLAIN plans, understand cost estimation, and apply optimiser hints
- Advanced JOIN Patterns: Anti-Joins, Semi-Joins, Cross & Lateral Joins — Use NOT EXISTS, EXISTS, CROSS APPLY, and LATERAL for complex join patterns
- Window Functions Mastery: PARTITION, ORDER, Frames, Ranking Functions — ROW_NUMBER, RANK, LAG, LEAD, and running totals with window functions
- Stored Procedures, Functions & Triggers (Advanced Use-Cases) — Write complex stored procedures, scalar functions, and audit triggers
- Transactions, Isolation Levels & Concurrency Control (ACID Deep Dive) — Read uncommitted to serializable — choose the right isolation level
- Locking, Deadlocks & High-Concurrency Performance Patterns — Understand row locks, table locks, and how to detect and prevent deadlocks
- Partitioning: Range, Hash, List & Composite Strategies — Partition large tables for query performance and maintenance efficiency
- Sharding & Distributed SQL Concepts (Vitess, Yugabyte, CockroachDB) — Scale SQL horizontally with sharding strategies and distributed databases
- Materialized Views, Caching Layers & Query Acceleration — Pre-compute expensive queries with materialized views and refresh strategies
- Advanced Aggregations & Pivot/Unpivot Techniques — GROUPING SETS, ROLLUP, CUBE, and pivot tables in SQL
- Recursive CTEs: Graph Traversal, Hierarchies & Path Queries — Traverse trees and graphs with recursive CTEs and anchor members
- Temporal Tables & Time-Travel Queries — Track historical data with system-versioned temporal tables and time-travel queries
- Full-Text Search & Fuzzy Matching Across SQL Engines — Implement full-text search with MATCH AGAINST, tsvectors, and fuzzy matching
- JSON & Semi-Structured Data Handling in SQL — Store, query, and index JSON data in PostgreSQL, MySQL, and SQL Server
- Advanced Data Types: Arrays, HSTORE, Geography, UUID — Use PostgreSQL's powerful extended types for arrays, key-value, and geo data
- Database Security: Roles, Privileges, Policies & Row-Level Security — Implement RBAC, column-level privileges, and row-level security policies
- SQL Injection Defenses & Secure Query Practices — Prevent SQL injection with parameterised queries and input validation
- Backup, Restore & High Availability Strategies — Plan database backups, test restores, and set up high availability
- Database Replication: Synchronous vs Asynchronous, Failover & Clustering — Set up primary/replica replication and automatic failover for your database
- Advanced Views & Virtual Tables for Reusable Query Logic — Build updatable views, security views, and virtual table patterns
- Analytical SQL for BI: Cubes, Rollups, Grouping Sets — Write BI-grade SQL with ROLLUP, CUBE, and GROUPING SETS
- Query Profiling Tools Across PostgreSQL, MySQL & SQL Server — Use EXPLAIN, ANALYZE, Performance Schema, and Query Store to profile queries
- Understanding Buffer Pool, Caches, Memory & I/O Optimization — Tune the buffer pool, shared buffers, and memory for faster query I/O
- Massive Data Handling: Bulk Inserts, Batching, ETL Patterns — Load millions of rows efficiently with COPY, bulk insert, and ETL patterns
- Triggers vs Application Logic — Architectural Best Practices — When to use DB triggers vs application code and how to avoid trigger pitfalls
- Schema Versioning, Migration Tools & CI/CD for Databases — Version database schemas with Flyway, Liquibase, and CI/CD pipelines
- Database Design Patterns for Large Systems (OLTP vs OLAP) — Choose between OLTP and OLAP schema designs for your workload
- Cross-Database Queries, Foreign Data Wrappers & Federated SQL — Query remote databases with FDWs, linked servers, and federated queries
- Performance Testing: Benchmarking, Stress Testing & Load Tools — Benchmark SQL performance with pgbench, sysbench, and custom load tests
- Designing Multi-Tenant Databases (Shared, Isolated, Hybrid Models) — Model multi-tenant SaaS databases with row-level, schema, or database isolation
- Data Warehousing Architecture & Star/Snowflake Schemas — Design analytical data warehouses with star schemas, fact tables, and dimensions
- Using SQL with Big Data Tools (Hive, SparkSQL, DuckDB, Presto) — Run SQL at massive scale with Hive, SparkSQL, DuckDB, and Presto
- Final Project – Build a Full Production-Ready SQL Database System — Design, build, and optimise a complete production database from scratch
- SQL vs NoSQL: When to Use Each — Document, key-value, wide-column and graph stores, ACID vs BASE, and the CAP theorem
- Streaming & Real-Time SQL — Continuous queries, windowing and watermarks with Flink SQL, ksqlDB and Materialize
- MERGE & UPSERT — Idempotent writes with INSERT ON CONFLICT, ON DUPLICATE KEY UPDATE and MERGE
- Vector & Similarity Search — Store embeddings and run k-nearest-neighbor search with pgvector distance operators