The Sample Database Used in This Path
Two small schemas - a company HR database and a shop sales database - used by every example in this SQL path. Create them once and follow along.
963 published notes across every category.
Two small schemas - a company HR database and a shop sales database - used by every example in this SQL path. Create them once and follow along.
CREATE defines the objects data lives in. Learn CREATE DATABASE, CREATE SCHEMA and CREATE TABLE, with column definitions and inline constraints.
ALTER changes a table that already holds data. Add and drop columns, change types, set defaults and manage constraints without losing rows.
Three ways to remove data, with very different consequences. Learn what each one destroys, what can be rolled back and what resets identity counters.
Every way to put rows into a table: explicit column lists, multi row VALUES, INSERT ... SELECT, defaults and handling duplicate keys.
UPDATE changes existing rows. Learn multi column updates, conditional logic with CASE, updates driven by a join and how to check the blast radius firs...
DELETE removes rows permanently. Learn targeted deletes, deleting through a join, soft deletes and the habits that stop a one line mistake becoming an...
The statement you will write more than all the others combined. Choose columns, alias them, and learn why SELECT * belongs in the console and not in c...
Compute values in the select list, build derived columns from existing ones, and use DISTINCT correctly - including what it does across several column...
Sorting on one or many columns, NULL placement, and the four dialect specific ways to fetch page two of a result set - including why OFFSET gets slow.
WHERE decides which rows survive. Learn the comparison operators, how conditions are evaluated per row, and why a function around a column kills an in...
Combining conditions correctly. Precedence between AND and OR, what NOT does to a NULL, and how to keep complex filters readable and index friendly.