Linux Today: Linux News On Internet Time.

O'Reilly Network: AboutSQL: DELETE Tips and Tricks

Jan 01, 2001, 21:06 (4 Talkback[s])
(Other stories by John Paul Ashenfelter)

"It's probably too easy to use the DELETE statement, thanks to the (fairly) consistent syntax of the SQL standard, but I think it's important to provide you with as much information as possible -- so here goes:

DELETE FROM table_name WHERE criteria

Now that you've seen it, I want to warn you in loud and unambiguous language to be EXTREMELY careful when you use it. There is no undo. And if you forget the WHERE clause or make a mistake in it, you run the risk of removing the entire table from the database!"

"Just like the UPDATE command, I heartily recommend trying a SELECT statement using the WHERE clause before you do a DELETE, just to make sure it works like you expect it to. And you should be exceptionally careful how you let users interface with the DELETE command because:

SQL Wisdom #2) If users CAN delete data, they WILL delete it ... accidentally and at the worst possible time."

Complete Story

Related Stories: