Table of contents
Text Link
Text Link

SQL DELETE statement

DELETE statement

To delete all the data from the table but not the table itself, use a query with a DELETE FROM statement.

For example, let's delete all the information from the following table titled books:

To do that with the query will be:

DELETE FROM books;

As a result of the query execution, the table books is empty now.

Share this article
Get more lessons
like this
Thank you! Your submission has been received!
Oops! Something went wrong.

Level up your tech skills and advance your career

• Wide range of SQL and Databases tracks

• Study at your own pace with your personal study plan

• Focus on practice and real-world experience

Learn SQL Free
No credit card required

Delete selected rows

Use DELETE FROM statement to delete only selected rows from a table.

For example, let's delete some information from the following table titled books:

Some books from the table are unavailable (their quantity equals zero). To delete records about these books, the query with a WHERE clause will be:

DELETE FROM books 
WHERE quantity = 0;

This query will delete all the rows from the table books where the logical expression

quantity = 0

is true.

After the execution of the query, the books table will look like this:

Get more articles like this
Thank you! Your submission has been received!
Oops! Something went wrong.

More on this

No items found.