Skip to main content
Course/Module 1/Topic 4 of 4Beginner

UPDATE & DELETE

Learn to modify existing data with UPDATE and remove rows with DELETE.

20 minBy Priygop TeamLast updated: Feb 2026

UPDATE and DELETE

UPDATE modifies existing rows in a table. DELETE removes rows. ALWAYS use WHERE with UPDATE and DELETE — without it, you will update or delete ALL rows in the table! This is one of the most common and dangerous mistakes in SQL.

UPDATE & DELETE Syntax

  • UPDATE table SET col=val WHERE condition — Modify rows
  • DELETE FROM table WHERE condition — Remove rows
  • ⚠️ Always use WHERE! Without it, ALL rows are affected
  • UPDATE can change multiple columns: SET col1=val1, col2=val2
  • Use SELECT first to verify which rows will be affected
  • TRUNCATE TABLE — Deletes all rows (faster than DELETE without WHERE)

UPDATE & DELETE Examples

Example
-- Update Alice's grade to 'A+'
UPDATE students
SET grade = 'A+'
WHERE name = 'Alice';

-- Update multiple columns at once
UPDATE students
SET age = 23, city = 'Pune'
WHERE id = 2;

-- ⚠️ DANGEROUS: This updates ALL rows!
-- UPDATE students SET grade = 'F';  -- DON'T DO THIS!

-- Delete a specific student
DELETE FROM students
WHERE id = 3;

-- Delete all students from Delhi
DELETE FROM students
WHERE city = 'Delhi';

-- ⚠️ DANGEROUS: This deletes ALL rows!
-- DELETE FROM students;  -- DON'T DO THIS!

-- Verify changes
SELECT * FROM students;

Try It Yourself: UPDATE & DELETE

Try It Yourself: UPDATE & DELETEJavaScript
JavaScript Editor
✓ ValidTab = 2 spaces
JavaScript|27 lines|857 chars|✓ Valid syntax
UTF-8

Quick Quiz

Chat on WhatsApp
Priygop - Leading Professional Development Platform | Expert Courses & Interview Prep