Skip to content

Computer Science · Ch 9 — Structured Query Language (SQL)

Data Deletion

9.7.2

Data Deletion

The Purpose of DELETE

The DELETE statement removes one or more entire records (rows) from a table. It does not remove the table structure itself — only the data inside it.

Syntax

DELETE FROM table_name WHERE condition;

The WHERE clause is what makes the deletion selective. Without it, every row in the table is removed.

Example from the Textbook

Suppose a student with RollNumber = 2 has left the school. The following MySQL command deletes that single record from the STUDENT table:

mysql> DELETE FROM STUDENT WHERE RollNumber = 2;
Query OK, 1 row affected (0.06 sec)

After deletion, a SELECT * query shows that the row for roll number 2 is gone. The remaining rows are:

RollNumberSNameSDateofBirthGUID
1Atharv Ahuja2003-05-15444444444444
3Taleem Shah2002-02-28101010101010
4John Dsouza2003-08-18333333333333
5Ali Shah2003-07-05101010101010
6Manika P.2002-03-10466444444666

Five rows remain, confirming that only the targeted record was removed.

Critical Caution

Watch out

Like the UPDATE statement, DELETE is dangerous without a WHERE clause. If you omit the condition, all records in the table are deleted — there is no warning or confirmation. Always double-check your WHERE condition before executing a DELETE command.

Key Points to Remember

  • DELETE removes entire rows, not individual column values. …