DELETE
The DELETE
statement is used to remove rows from a table. You can delete specific records or clear entire datasets.
Basic Syntax
The example below shows how to delete a record from a table using the DELETE
statement:
DELETE FROM table_name WHERE condition;
DELETE FROM
specifies the table.WHERE
defines which rows to remove.
Without a
WHERE
clause, all rows in the table will be deleted.
DELETE Statement Example
The query below deletes the record of the client named Jason Green.
DELETE FROM clients WHERE name = 'Jason Green';
This command deletes the record of the client named Jason Green.
Delete All Rows
To clear all data from a table but keep the table structure, you can use the following query:
DELETE FROM clients;
Be cautious: this action cannot be undone unless a backup is available.
What's Next?
Next, you'll explore different data types used in SQL such as TEXT
, INT
, and REAL
.
What is the main purpose of the DELETE statement in SQL?
To add a new column
To change data in a column
To remove records from a table
To create a new table
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help
Code Editor
Tables
Execution Result