Domain 2 β€” Module 3 of 7 43%
10 of 27 overall
Domain 2: Relational Data on Azure Free ⏱ ~12 min read

SQL Basics: SELECT, INSERT, UPDATE, DELETE

SQL is the universal language of relational databases. Learn the four essential commands that let you talk to any database.

What is SQL?

Simple explanation

SQL is how you talk to a database.

Just like you ask a librarian β€œShow me all books by this author” or β€œAdd this new book to the shelf,” SQL is the language you use to ask a database questions and give it instructions. Every relational database understands SQL.

There are four basic things you can say: SELECT (show me data), INSERT (add new data), UPDATE (change existing data), and DELETE (remove data).

The four core SQL statements

SELECT β€” read data

The most common SQL statement. It retrieves data from one or more tables.

-- All drivers
SELECT * FROM Drivers;

-- Specific columns with a filter
SELECT Name, LicenceClass
FROM Drivers
WHERE HireDate > '2024-01-01';

-- Count deliveries per driver
SELECT DriverID, COUNT(*) AS TotalDeliveries
FROM Deliveries
GROUP BY DriverID;

Key clauses:

  • SELECT β€” which columns to return
  • FROM β€” which table(s) to query
  • WHERE β€” filter rows
  • ORDER BY β€” sort results
  • GROUP BY β€” group rows for aggregation (COUNT, SUM, AVG)
  • JOIN β€” combine rows from multiple tables

INSERT β€” add new data

-- Add a new driver
INSERT INTO Drivers (DriverID, Name, LicenceClass, HireDate)
VALUES ('D003', 'Ana Reyes', 'Class 5', '2026-04-20');

UPDATE β€” change existing data

-- Update a driver's licence class
UPDATE Drivers
SET LicenceClass = 'Class 2'
WHERE DriverID = 'D003';

Always include a WHERE clause β€” without it, every row gets updated.

DELETE β€” remove data

-- Remove a driver
DELETE FROM Drivers
WHERE DriverID = 'D003';

Always include a WHERE clause β€” without it, every row gets deleted.

SQL statement categories

SQL statement categories
FeatureDMLDDLDCL
Full nameData Manipulation LanguageData Definition LanguageData Control Language
PurposeWork with dataDefine structureManage access
Key statementsSELECT, INSERT, UPDATE, DELETECREATE, ALTER, DROPGRANT, REVOKE, DENY
ExampleSELECT * FROM DriversCREATE TABLE Drivers (...)GRANT SELECT ON Drivers TO analyst_role

DDL examples

-- Create a new table
CREATE TABLE Products (
  ProductID INT PRIMARY KEY,
  Name VARCHAR(100) NOT NULL,
  Price DECIMAL(10,2)
);

-- Add a column to an existing table
ALTER TABLE Products
ADD Category VARCHAR(50);

-- Delete a table entirely
DROP TABLE Products;
JOINs β€” connecting tables

The real power of SQL is joining tables. A JOIN combines rows from two tables based on a related column.

-- Show each delivery with the driver's name
SELECT d.DeliveryID, d.Destination, dr.Name AS DriverName
FROM Deliveries d
JOIN Drivers dr ON d.DriverID = dr.DriverID;

Common join types:

  • INNER JOIN β€” only rows that match in both tables
  • LEFT JOIN β€” all rows from the left table, matched rows from the right (nulls if no match)
  • RIGHT JOIN β€” all rows from the right table, matched rows from the left
  • FULL JOIN β€” all rows from both tables
Exam tip: SQL statement matching

The exam gives you a task and asks which SQL statement to use:

  • β€œRetrieve all orders from last month” β†’ SELECT with WHERE
  • β€œAdd a new customer record” β†’ INSERT
  • β€œChange a customer’s email address” β†’ UPDATE
  • β€œRemove cancelled orders” β†’ DELETE
  • β€œCreate a new table for products” β†’ CREATE TABLE (DDL)
  • β€œGive the analyst team read access” β†’ GRANT (DCL)

Flashcards

Question

What are the four DML (Data Manipulation Language) SQL statements?

Click or press Enter to reveal answer

Answer

SELECT (read data), INSERT (add new rows), UPDATE (modify existing rows), DELETE (remove rows). These are the core commands for working with data in a relational database.

Click to flip back

Question

What is the difference between DDL and DML?

Click or press Enter to reveal answer

Answer

DDL (Data Definition Language) defines database structure β€” CREATE, ALTER, DROP tables. DML (Data Manipulation Language) works with the data inside those tables β€” SELECT, INSERT, UPDATE, DELETE.

Click to flip back

Question

What does a SQL JOIN do?

Click or press Enter to reveal answer

Answer

A JOIN combines rows from two or more tables based on a related column (usually a foreign key to primary key match). It lets you query across related data β€” like showing delivery details alongside driver names.

Click to flip back

Knowledge check

Knowledge Check

Tom wants to see all deliveries that were completed in April 2026, sorted by date. Which SQL statement type does he need?

Knowledge Check

Jake needs to create a new Products table in his CloudPulse database. Which category of SQL does this fall under?

Next up: Database Objects: Views, Indexes & More β€” beyond tables, what else lives inside a database?