The UPDATE statement is a core Data Manipulation Language (DML) command used to modify existing values in table columns. Unlike INSERT (which adds new rows), UPDATE alters attributes in rows that already exist.
UPDATE table_name
SET column1 = new_value1, column2 = new_value2
WHERE filter_condition;
-- 1. Update single column for a specific student
UPDATE students
SET gpa = 3.90
WHERE student_id = 1;
-- 2. Update multiple columns simultaneously
UPDATE students
SET course = 'MCA', gpa = 3.82
WHERE student_id = 4;
-- 3. Perform mathematical updates (e.g., 5% scholarship boost)
UPDATE students
SET gpa = gpa + 0.10
WHERE course = 'BCA' AND gpa <= 3.80;
SELECT query with the exact same WHERE condition before running an UPDATE to verify which rows will be affected!
Next, let us learn how to remove records safely using the SQL DELETE Statement!
Every single row in the entire table will be updated to the new value! This is one of the most disastrous operational accidents in database management.
Safe Updates mode (SET SQL_SAFE_UPDATES = 1) prevents executing UPDATE or DELETE statements that lack a WHERE clause utilizing a Key/Index, protecting databases against accidental data loss.
Yes! Separate multiple column assignments with commas: SET col1 = val1, col2 = val2 WHERE condition.
Proceed to the next class in sequence to build production mastery of relational database architecture.
Continue to Class 22: DELETE Statement → Previous: ← LIMIT & OFFSET | Full Syllabus
Preventing disastrous accidental updates across all table rows.
Updating multiple distinct conditions in a single query.
Wrapping updates in BEGIN TRANSACTION and COMMIT.
How UPDATE acquires Exclusive (X) locks on modified rows.