|
The DELETE statement Continued from The UPDATE statement The DELETE statement is used to delete rows from a named table. As in the UPDATE statement, all rows that meet the conditions in the WHERE clause are deleted. (Since there is no UNDO statement or "Are you sure?" warning in SQL, use caution before executing this statement.) If the powers that be decided to eliminate the Los Angeles office and lay off all the workers, the following SQL statement could do the dirty work: DELETE FROM EMPLOYEES WHERE BRANCH_OFFICE = 'Los Angeles'; As with the UPDATE statement, omitting the WHERE clause would affect all of the rows in the table. The syntax diagram for the DELETE statement as shown is as follows: DELETE FROM table [ WHERE predicate [ { logical-connector predicate } ] ]; That wraps up our section on the primary data manipulation language (DML) statements. We haven't covered everything SQL can do--not by a long shot. SQL offers many more facilities, like the ability to determine averages, sums, and other calculations from table data and the ability to perform queries involving data from more than one table (multitable queries, also called joins). The language also lets you control users' data-access permissions, with the GRANT and REVOKE commands. For those who want to learn more about SQL, there are several excellent books on the market. The definitive work on the SQL-92 standard is A Guide to the SQL Standard, by C. J. Date with Hugh Darwen (Addison-Wesley). For a less formal presentation, see Understanding the New SQL: A Complete Guide, by Jim Melton and Alan R. Simon (Morgan Kaufman). Published as PC Tech Feature in the 11/17/98 issue of PC Magazine.
Elsewhere on ZDNet
|
|
TOP |
Copyright (c) 1998 Ziff-Davis Inc. |