Deleting Data

Deleting data from a table is even easier than adding or updating data—perhaps too easy.

You use the SQL DELETE statement to delete data. The statement takes only two parameters—one required and one optional:

  • The name of the table from which to delete the data must be specified immediately following the words DELETE FROM.

  • An optional WHERE clause can be used to restrict the scope of the deletion process.

The DELETE statement is dangerously easy to use. Look at the following line of code (but don’t execute it):

DELETE FROM Directors

This statement removes all directors from the Directors table, and does it without any warnings or confirmation.

Tip

Some databases, in particular client/server databases (such as Microsoft SQL Server ...

Get Adobe ColdFusion 8 Web Application Construction Kit, Volume 1: Getting Started now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.