DELETE Statements

This YouTube video was created by Steve Griffith.

The DELETE statement is use to remove one or more records from a database table. The structure of the DELETE statement is similar to the SELECT statement. It is followed by the FROM clause and the table name. A WHERE clause is used to specify which records to remove from the database table.

WARNING

If the WHERE clause is omitted, ALL records will be removed. There is no UNDO command on a database.

NOTE

Because the primary key column of each record has a unique value throughout the table, it is best practice to use the primary key column when deleting records.

# Remove the movie with the movie_id of 24
DELETE 
FROM movies 
WHERE movie_id = 24;

Multiple records can be deleted by adjusting the WHERE clause.

# Remove all movies with a movie_id greater than 23
DELETE 
FROM movies 
WHERE movie_id > 23;