Modify existing rows with UPDATE ... SET ... WHERE
Remove rows with DELETE FROM ... WHERE
Understand why WHERE is critical in UPDATE and DELETE
📊 Data Modification Simulator
Run INSERT, UPDATE, and DELETE commands on a live in-memory students table. The table updates in real time. Use SELECT to see current state.
INSERT
INSERT adds a new row to a table. List the columns in parentheses, then provide the matching values in the same order. You can insert multiple rows in one statement by separating value groups with commas.
INSERT INTO students (name, grade, score, city) VALUES ('Grace', 11, 90, 'Tulsa');
UPDATE
UPDATE modifies existing rows. SET specifies which columns to change and their new values. WHERE identifies which rows to change. Without WHERE, every row in the table is updated — a common and costly mistake.
UPDATE students SET score = 95 WHERE name = 'Bob';
DELETE
DELETE removes rows from a table. Like UPDATE, always include WHERE. DELETE FROM students with no WHERE deletes every row. Some teams use "soft delete" — add a deleted_at column instead of actually removing rows.
DELETE FROM students WHERE id = 5; — safe: targets one specific row by ID.
Quick Check
1. What happens if you run UPDATE students SET score = 0 without a WHERE clause?
SQL throws an error
Every row in the students table gets score = 0
Only the first row is updated
The update is ignored without a WHERE
2. What is the correct INSERT syntax?
ADD INTO students VALUES ('Alice', 10)
INSERT INTO students (name, grade) VALUES ('Alice', 10)
INSERT students SET name='Alice', grade=10
CREATE ROW students (name='Alice', grade=10)
3. What is "soft delete"?
A DELETE that runs slowly to avoid database locks
Marking a row as deleted (e.g., with a deleted_at timestamp) instead of actually removing it
Using DELETE with LIMIT 1
Deleting only columns, not rows
4. What is the safest way to target a single row for UPDATE or DELETE?
Use WHERE name = 'Alice' (names might not be unique)