Concept Flow - UPDATE without WHERE (danger)
Start UPDATE statement
Check for WHERE clause
Finish
The UPDATE command checks if there is a WHERE clause. If yes, it updates only matching rows. Without WHERE, it updates every row in the table.
UPDATE employees SET salary = salary * 1.1;
| Step | Action | Rows Affected | Table State Change |
|---|---|---|---|
| 1 | Start UPDATE employees SET salary = salary * 1.1 | 0 | No change yet |
| 2 | Check for WHERE clause | N/A | No WHERE clause found |
| 3 | Apply salary = salary * 1.1 to ALL rows | 5 | All 5 employee salaries increased by 10% |
| 4 | Finish UPDATE | 5 | Table updated with new salaries for all rows |
| Variable | Start | After Update | Final |
|---|---|---|---|
| salary (per employee) | Original salaries | Increased by 10% | Updated salaries |
UPDATE table_name SET column = value Without WHERE, all rows are updated. Always use WHERE to limit updates. Missing WHERE can cause unintended data changes. Check your query before running UPDATE.