DELETE Statement SQL

The DELETE statement is designed to delete rows from a table. It can delete one row, just a few or ALL of the rows in a table. A simple example from our monopoly_prop table: We sell Marvin Gardens and wish to remove it:

DELETE * FROM monopoly_prop WHERE name = 'Marvin Gardens'

If we have two properties named 'Marvin Gardens' this would take them both out.

Programmers should have a care when playing with the DELETE statement, it would be very easy to empty a table of rows - eliminating all of the data. The following example would do the trick.

DELETE * FROM monopoly_prop

Another danger of the DELETE statement is that once something is deleted it is not possible to retrieve the data unless a backup of the table or database is maintained.


Send notes in disappearing ink!

Interesting Pages