3.6. The DELETE Command
Earlier in the chapter, we saw that the DELETE command can be used to remove all rows of a table. In this section we revisit the powerful DELETE. Keep in mind as you read this that the DELETE statement can affect multiple rows as we have seen and hence, one must be careful when using it. Following is the general syntax of the DELETE command used to delete rows from a table:
DELETE FROM Table
WHERE (condition)
(condition) determines which rows of the table will be deleted. As you saw earlier, if no WHERE condition is used, all the rows of the table will be deleted.
 | Multiple rows can be affected by the DELETE command, so be careful when using it. |
|
Here is an example of using the DELETE command on our original Employee table:
DELETE FROM Employee
WHERE salary < 1500
Now if you type:
SELECT *
FROM EMPLOYEE
You will get the following four rows of output:
names address employee_number salary
-------------------- -------------------- --------------- ------------
Joe Smith 123 4th St. 101 2500.00
Pradeep Saha 27 Shillingford 103 3300.00
Joya Das 23 Pesterfield Cr 114 2290.00
Terry Livingstone 465 Easter Ave 95 3390.00
(4 row(s) affected)
|