SQL Topic collection
Database Changes SQL Topic exercises
Practice safe SQL data changes, schema evolution, retry-safe upserts, transactions, rollback, views, and indexes in isolated databases.
- Exercises
- 10
- Difficulty
- Beginner to Hard
What this collection tests
Skills and query patterns
INSERT, predicate-safe UPDATE and DELETE, CREATE and ALTER, upserts, transaction boundaries, rollback, views, and composite indexes
Curated exercises
Choose an exercise
Work in the live editor where supported. Advanced guided labs state their engine boundary before you open the workspace.
- Exercise 1Beginner
Add a New Customer Account
Insert account 5 as Summit Health with tier growth, status active, and a 15000 credit limit.
- INSERT
- Explicit column lists
SQLite + PostgreSQL live · 3 guided
Open exercise → - Exercise 2Easy
Escalate Pending Orders Safely
Change pending orders for account 1 to review.
- UPDATE
- Predicate safety
SQLite + PostgreSQL live · 3 guided
Open exercise → - Exercise 3Easy
Remove Expired Cancelled Orders
Delete cancelled orders placed before 2025-01-01.
- DELETE
- Predicate safety
- Date filtering
SQLite + PostgreSQL live · 3 guided
Open exercise → - Exercise 4Hard
Upsert a Retry-Safe Account Sync
Upsert account 2 so Northstar Growth is enterprise, active, and has a 14000 credit limit.
- UPSERT
- Idempotency
SQLite + PostgreSQL live · 3 guided
Open exercise → - Exercise 5Easy
Create an Account Notes Table
Create account_notes with note_id, account_id, note_text, and created_at.
- Table creation
- Keys and constraints
SQLite + PostgreSQL live · 3 guided
Open exercise → - Exercise 6Medium
Add and Backfill Account Risk
Add risk_rating VARCHAR(10), then set it to high for credit limits at least 20000 and standard otherwise.
- Schema migration
- Data backfill
- CASE expressions
SQLite + PostgreSQL live · 3 guided
Open exercise → - Exercise 7Easy
Publish an Active-Account View
Create active_account_summary exposing account_id, account_name, tier, and credit_limit for active accounts.
- Views
- Filtering
SQLite + PostgreSQL live · 3 guided
Open exercise → - Exercise 8Medium
Commit a Coordinated Account Upgrade
In one transaction, add 1000 to account 2's credit limit and insert order 505 for 1000 with pending status and date 2025-03-01.
- Transactions
- COMMIT
- Atomicity
SQLite + PostgreSQL live · 3 guided
Open exercise → - Exercise 9Medium
Roll Back a Rejected Account Closure
Start a transaction, set account 3 to inactive, delete its pending orders, and then roll back the entire simulation.
- Transactions
- ROLLBACK
- Atomicity
SQLite + PostgreSQL live · 3 guided
Open exercise → - Exercise 10Medium
Index the Account Order Lookup
Create idx_orders_account_status on orders(account_id, status).
- Composite indexes
- Index design
SQLite + PostgreSQL live · 3 guided
Open exercise →
Attempt
Write a query or design from the brief before opening any hints.
Validate
Run it against the included dataset and inspect the output.
Explain
Compare the verified answer and explain each choice aloud.
Learn before practicing Database Changes
Strengthen your understanding with these targeted learning topics:
Continue practicing
Build the next SQL skill
WHERE Clause & Filtering
Practice SQL WHERE clauses with realistic boundary, NULL, text, date, exclusion, and production-filtering problems.
SQL Joins
Practice reliable INNER, LEFT, FULL, CROSS, self, semi, anti, range, temporal, and many-to-many join patterns.
Basic SQL Functions
Practice production-oriented string cleanup, numeric transformations, NULL handling, tolerant conversion, and delimiter parsing.
Open the interactive workspace and practice across SQL topics.