www.virtual-world.com

PC Magazine

  PC Tech

Handling Data with SQL

Introduction

The INSERT statement

The SELECT statement

Defining Selection Criteria

Comparisons and Logical Connectors

Nulls and Three-Valued Logic

The UPDATE statement

The DELETE statement



X10.com - The SuperSite for Home Automation!

NextCard Internet Visa - Apply Now

 
  Categories
Software

Related Stories
SQL: The Universal Database Language
-- 11/3/98

Handling Data with SQL
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
Learn SQL Online -- ZD University
Business Software: Databases -- ZD Products

 
 SPONSORED LINKS
@Backup   Your Solid Online Backup Plan. Download Now.
Services   9c/MINUTE LONG DISTANCE, 5c/MINUTE ON SUNDAYS!
STORAGE   Quantum means non-stop business, 24 hours a day
Software   X10.com -- The SuperSite for Home Automation
Books   Bargain Books up to 90% off at barnesandnoble.com
 ZDNET FEATURED LINKS
Downloads   Check out the best new downloads in Reviewer's Raves
Bargains!   Shop the Basement for best buys on computer products
Free Help   Got computing questions? ZDHelp has all the answers!
 MAGAZINE OFFERS
Free Offer   Get a FREE SUBSCRIPTION to Inter@ctive Week

TOP
Copyright (c) 1998 Ziff-Davis Inc.