DELETE Query in SQLite

SQLite DELETE Query To delete the existing records from a table, the DELETE query is used in SQLite.

Syntax:

DELETE FROM table_name  
WHERE conditions;

Example 1: TEACHERS Table:

ID NAME SUBJECT
1 Jim English
2 John Geology
3 Watson French
4 Holmes Chemistry
5 Tony Physics

Example:

DELETE FROM TEACHERS 
WHERE ID = 2;

Explanation: Here we have deleted the row from an already existing table “TEACHERS” where ID is 2. To verify the table data execute the below query. SELECT * FROM TEACHERS;

Output:

ID NAME SUBJECT
1 Jim English
3 Watson French
4 Holmes Chemistry
5 Tony Physics

Example 2:

DELETE FROM TEACHERS;

Explanation: Here we have deleted all the rows from an already existing table “TEACHERS”, but not the table itself. To verify the table data execute the below query. SELECT * FROM TEACHERS;

Please follow and like us:
Content Protection by DMCA.com