English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

SQLite DELETE Query

SQLite DELETEQueries are used to delete existing records from a table. You can use the WHERE clause with the DELETE query to delete selected rows, otherwise all records will be deleted.

Syntax

The following is the basic syntax of DELETE query with WHERE clause.

DELETE FROM table_name WHERE [condition];

You can combine n conditions using AND or OR operators.

Online Example

Please see the COMPANY table with the following records.

ID          NAME        AGE         ADDRESS     SALARY
----------  ----------  ----------  ----------  ----------
1           Paul        32          California  20000.0
2           Allen       25          Texas       15000.0
3           Teddy       23          Norway      20000.0
4           Mark        25          Rich-Mond   65000.0
5           David       27          Texas       85000.0
6           Kim         22          South-Hall  45000.0
7           James       24          Houston     10000.0

Below is an example that will delete the record with ID7customer.

sqlite> DELETE FROM COMPANY WHERE ID = 7;

Now the COMPANY table will have the following records.

ID          NAME        AGE         ADDRESS     SALARY
----------  ----------  ----------  ----------  ----------
1           Paul        32          California  20000.0
2           Allen       25          Texas       15000.0
3           Teddy       23          Norway      20000.0
4           Mark        25          Rich-Mond   65000.0
5           David       27          Texas       85000.0
6           Kim         22          South-Hall  45000.0

If you want to delete all records from the COMPANY table, there is no need to use the WHERE clause with the DELETE query as shown below-

sqlite> DELETE FROM COMPANY;

Currently, the COMPANY table has no records because all records have been deleted by the DELETE statement.