PGoCareerGoCareer prep tools
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

SQL · Theory

UPDATE Record

← All stacks

Theory

33/439

UPDATE Record

UPDATE students SET marks = 80 WHERE roll = 12; changes matching rows. SET is what to change. WHERE is which rows. Without WHERE, every student becomes 80. Workbench safe-updates mode blocks UPDATE/DELETE without a key — that is a seatbelt, not a bug.

Preview: SELECT * FROM students WHERE roll = 12; then UPDATE. In a transaction: START TRANSACTION; UPDATE …; SELECT to check; COMMIT or ROLLBACK.

Trap — WHERE name = 'Asha' when two Ashas exist. Use the PRIMARY KEY. Trap: marks = marks + 1 without WHERE.

On the example next to this theory — UPDATE Record — uPDATE changes existing rows — always scope with WHERE.

Exam tip

UPDATE … SET … WHERE roll = 12. Never skip WHERE.

UPDATE Record — sample query

CREATE TABLE products (id INTEGER PRIMARY KEY, name TEXT, price REAL);
INSERT INTO products VALUES (1, 'Mouse', 499);
UPDATE products SET price = 449 WHERE id = 1;
SELECT * FROM products;

UPDATE Record — uPDATE changes existing rows — always scope with WHERE.

Short notes

  • DefUPDATE t SET col = val WHERE key = …;
  • RuleAlways WHERE on a key. Preview with SELECT.
  • TrapMissing WHERE updates the whole table.

Questions

1

Write an UPDATE.

2

What if you omit WHERE?

33 / 439

P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.