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:
As a result of the query execution, the table books is empty now.
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:
This query will delete all the rows from the table books where the logical expression
is true.
After the execution of the query, the books table will look like this:
Master SQL by choosing your ideal learning course
View all courses
Databases with SQL and Python
4.7
Explore the world of SQL and its role in retrieving, storing, and processing data, empowering you to make informed decisions and drive impactful insights.
19 projects
2K already learning
SQL for Backend Developers
4.2
Choose this track to master the fundamentals of database theory, learn SQL statements to access data, and gain practical experience with MySQL.
7 projects
1K already learning