Basic SQL Commands
Basic SQL commands are the five statements that cover most everyday database work: CREATE defines a new table and its structure, SELECT reads rows, INSERT adds new rows, UPDATE changes existing rows that match a condition, and DELETE removes rows that match a condition. Each command does exactly one job.
A small handful of SQL commands account for the overwhelming majority of real-world database work. Understanding these five deeply, rather than memorizing every possible SQL feature, covers what almost every application actually does with its database.
The five core commands
- CREATE: defines a new table (or database, view, index) and its structure.
- SELECT: reads rows out of one or more tables, optionally filtered, sorted, and limited.
- INSERT: adds new rows to a table.
- UPDATE: changes existing rows that match a condition.
- DELETE: removes existing rows that match a condition.
A worked example, all five in sequence
CREATE TABLE tasks (
task_id INT PRIMARY KEY,
title VARCHAR(200),
is_done BOOLEAN DEFAULT false
);
INSERT INTO tasks (task_id, title) VALUES (1, 'Write report');
INSERT INTO tasks (task_id, title) VALUES (2, 'Review PR');
SELECT * FROM tasks WHERE is_done = false;
-- returns both rows, since is_done defaults to false
UPDATE tasks SET is_done = true WHERE task_id = 1;
SELECT * FROM tasks WHERE is_done = false;
-- now returns only task_id 2
DELETE FROM tasks WHERE is_done = true;
SELECT * FROM tasks;
-- returns only task_id 2, the completed one was removed
Each command does exactly one job: CREATE sets up the shape, INSERT populates it, SELECT reads it back with a real filter condition, UPDATE changes a matching row in place, and DELETE removes a matching row entirely.
A critical warning worth stating plainly
UPDATE and DELETE without a WHERE clause apply to every single row in the table. DELETE FROM tasks; with no WHERE clause deletes every row in the table, not just one. This is one of the most common and most damaging real mistakes made against production databases, always double-check the WHERE clause before running an UPDATE or DELETE, ideally by first running the equivalent SELECT with the same condition to see exactly which rows would be affected.
Where this matters in real systems
Because of the real risk above, production database access is often restricted so that ordinary application code can only run parameterized, pre-reviewed queries, and direct ad-hoc UPDATE/DELETE access to production data is treated as a genuinely dangerous operation requiring extra caution or a second reviewer, exactly because a missing WHERE clause can silently wipe out an entire table in production in under a second.
What interviewers actually ask about basic SQL commands
- "What are the five most commonly used SQL commands?" CREATE, SELECT, INSERT, UPDATE, DELETE.
- "What happens if you run UPDATE or DELETE without a WHERE clause?" It applies to every row in the table, changing or deleting all of them, not just one.
- "How would you safely test a DELETE before running it?" Run the equivalent SELECT with the same WHERE condition first, to see exactly which rows would be affected.
- "What's the difference between DELETE and UPDATE?" DELETE removes matching rows entirely; UPDATE changes specific column values on matching rows while keeping the row itself.
Key takeaways
- CREATE, SELECT, INSERT, UPDATE, and DELETE cover the large majority of everyday SQL work.
- SELECT reads data with a filter, INSERT adds new rows, UPDATE changes existing rows, DELETE removes them.
- UPDATE and DELETE without a WHERE clause affect every row in the table, a real and common source of accidental data loss.
- Testing a DELETE's WHERE clause with an equivalent SELECT first is a genuinely useful safety habit.
More in SQL
Browse all DBMS topics
Log in to save which topics you've read across every subject.
Frequently asked questions
What are the five most commonly used SQL commands?
CREATE, SELECT, INSERT, UPDATE, DELETE.
What happens if you run UPDATE or DELETE without a WHERE clause?
It applies to every row in the table, changing or deleting all of them, not just one.
How would you safely test a DELETE before running it?
Run the equivalent SELECT with the same WHERE condition first, to see exactly which rows would be affected.
What's the difference between DELETE and UPDATE?
DELETE removes matching rows entirely; UPDATE changes specific column values on matching rows while keeping the row itself.