General Note: Here we have pulled in the data from a sample database. You can download it from the following link and use it for practicing Click Here For Sample Database

In this tutorial, you will learn the use of DELETE keyword in SQLite.

By using the delete keyword you can delete all rows on N number of rows from table. You have to be careful while using the delete keyword also. Because it will cause data loss.

Syntax:


DELETE FROM table_name[WHERE condition];

Same as like update query, the where condition is optional here. However, if you skip where condition it will delete all the records from the table.so while updating and deleting where condition is more mandatory or else you will lose your data.

Here am creating a new table to demonstrate the delete event using the create…select keyword.


Create table sample1 as select mobile_name,price,sold_count,os_name from mobile_sales_details

Here am going to delete rows whose price is greater than 20,000


Delete from sample1 where price > 20000

So it will remove only rows whose price is greater than 20,000. If you want to remove entire table data use the below query.

Delete from sample1

*delete only removes data from table. It will not remove the table.

If you want to remove the table use DROP command (DDL command) and truncate is not supported by SQLite