DELETE

SQL DELETE Keyword

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

Tutorials dojo strip

SQL DELETE Syntax

DELETE FROM table_name
WHERE condition;

If you omit the WHERE clause:

DELETE FROM table_name;

The first form deletes only the records that match the condition. The second form deletes all rows in the table.

SQL DELETE Deleting Specific Records Example

The following SQL statement deletes the patient with the last name 'Garcia' from the Patients table:

DELETE FROM Patients
WHERE last_name = 'Garcia';

Note: Be careful when deleting records in a table. Notice the WHERE clause in the DELETE statement. The WHERE clause specifies which record or records should be deleted. If you omit the WHERE clause all records in the table will be deleted.

SQL DELETE Deleting All Rows in a Table Example

It is possible to delete all rows in a table without deleting the table. This means that the table structure attributes and indexes will be intact.

The following SQL statement deletes all rows in the Patients table without deleting the table:

DELETE FROM Patients;

SQL DELETE Labs

Tutorials dojo strip
Scroll to Top