Java Reference
In-Depth Information
DELETE FROM
tableName
WHERE
criteria
where
tableName
is the table from which to delete. The optional
WHERE
clause specifies the
criteria used to determine which rows to delete. If this clause is omitted, all the table's rows
are deleted. The
DELETE
statement
DELETE FROM
Authors
WHERE
LastName = 'Black'
AND
FirstName = 'Sue'
deletes the row for Sue Black in the
Authors
table. If we know the
AuthorID
in advance
of the
DELETE
operation, the
WHERE
clause can be simplified as follows:
WHERE
AuthorID = 5
Figure 24.22 shows the
Authors
table after the
DELETE
operation has taken place.
AuthorID
FirstName
LastName
1
Paul
Deitel
2
Harvey
Deitel
3
Abbey
Deitel
4
Dan
Quirk
5
Michael
Morgano
Fig. 24.22
|
Sample data from table
Authors
after a
DELETE
operation.
This chapter's examples use Oracle's pure Java database
Java DB
, which is installed with
Oracle's JDK on Windows, Mac OS X and Linux. Before you can execute this chapter's
applications, you must set up in Java DB the
books
database that's used in Sections 24.6-
24.7 and the
addressbook
database that's used in Section 24.8.
For this chapter, you'll be using the embedded version of Java DB. This means that
the database you manipulate in each example must be located in that example's folder.
This chapter's examples are located in two subfolders of the
ch24
examples folder—
books_examples
and
addressbook_example
. Java DB may also act as a server that can
receive database requests over a network, but that is beyond this chapter's scope.
JDK Installation Folders
The Java DB software is located in the
db
subdirectory of your JDK's installation directo-
ry. The directories listed below are for Oracle's JDK 7 update 51:
•
32-bit JDK on Windows:
C:\Program Files (x86)\Java\jdk1.7.0_51
•
64-bit JDK on Windows:
C:\Program Files\Java\jdk1.7.0_51