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

SQL · Theory

How to Delete a Row

← All stacks

Theory

343/439

How to Delete a Row

DELETE FROM students WHERE roll = 12; removes matching rows. The table remains. DELETE FROM students; with no WHERE deletes everyone — same danger as UPDATE.

FOREIGN KEY: you cannot delete Asha if marks rows still point to her roll, unless ON DELETE CASCADE. That is a feature. Don’t disable FK to ‘make DELETE work’ in production.

Trap — DELETE vs DROP vs TRUNCATE mixed up. DELETE = rows. TRUNCATE = all rows, keep table. DROP = table gone.

On the example next to this theory: How to Delete a Row — dELETE removes matching rows. TRUNCATE clears a whole table faster (MySQL).

Exam tip

DELETE FROM students WHERE roll = 12;

How to Delete a Row — sample query

CREATE TABLE tags (id INTEGER PRIMARY KEY, label TEXT);
INSERT INTO tags VALUES (1, 'old'), (2, 'keep');
DELETE FROM tags WHERE label = 'old';
SELECT * FROM tags;

How to Delete a Row — dELETE removes matching rows. TRUNCATE clears a whole table faster (MySQL).

Short notes

  • DefDELETE FROM t WHERE …; removes rows.
  • RuleWHERE on the key. FKs may block the delete.
  • TrapDELETE / TRUNCATE / DROP confusion.

Questions

1

Write a DELETE.

2

DELETE vs TRUNCATE vs DROP?

343 / 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.