SQL Delete – Removing data from table

SQL Delete table example – Learn how to Delete data from a table in MySQL database with example and important points.

SQL delete statement used to delete a single record or multiple records from the database tables.

SQL syntax for deleting records from database table.

Syntax:

Delete from table_name where <condition>;

SQL query to delete all records from the BOOKS table

Query example:  Delete from books;

BY using above query, you can delete all the records from the BOOKS  table.

SQL query to delete a single record from database table

Query example: Delete from books where ISBN_NO= 209;

By using above query, we can delete a record with ISBN_NO= 209;

Result set after deleting a single record from the BOOKS table.

Query example: select *  from books;

Output:

ISBN_NOTITLEAUTHORFIRSTNAMEAUTHORLASTNAME
181The CastleFranzKalka
191Animal FarmGeorgeOrwell
205MadhushalaHarivanshRai

Points to notice: 

  1. The where clause specifies which records that should be deleted from the database table.
  2. Without where clause all the records in the database table will be deleted.
  3. By using delete command we can delete all the records without getting damage to database tables structure.

Related Posts