SQL DELETE Statement

The DELETE statement is used to delete existing records in a table.

Just as you insert records into a table with the INSERT statement, you can delete records from a table as well with the DELETE statement.


DELETE FROM table_name WHERE condition;

Delete Records Based on Conditions

The following statement will delete the rows from persons table where id is greater than 3.

DELETE FROM persons WHERE id > 3;

Delete All Data

Similarly, as mentioned above if you do not specify the WHERE clause in the DELETE statement all the rows from the table will be deleted. However, the target table itself won't be deleted that means the table structure, attributes, and indexes will remain intact.

The following statement will remove all the records from the persons table:

DELETE FROM persons;