Deleting Data from Database Tables

Delete Rows in a table

The DELETE statement is used to delete rows in a table.
SQL DELETE Syntax

DELETE FROM table_name [WHERE condition] [ORDER BY column_name] [LIMIT row_count]

The WHERE clause specifies which record or records that should be deleted. If you omit the WHERE clause, all records will be deleted!

If the ORDER BY clause is specified, the rows are deleted in the order that is specified.

The LIMIT clause places a limit on the number of rows that can be deleted.

Delete All Rows

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:

DELETE FROM table_name

or

DELETE * FROM table_name

Leave a Comment