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 Syntax
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 a client by name
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 all records
DELETE FROM clients;
Be cautious: this action cannot be undone unless a backup is available.
Want to learn more?
Join CodeFriends Plus membership or enroll in a course to start your journey.