Java Reference
In-Depth Information
Table 11-5
SQL Statements
STATEMENT
SYNTAX
ACTION
DROP
DROP INDEX indexName ON tableName
Delete index, indexName, on table, tableName
DROP TABLE tableName
Delete table, tableName, from database, deleting
all data in table
CREATE
CREATE TABLE tableName (fieldName1
Create new table in database; constraints may be
data Type Specification[, fieldName2
specified for each field after data type
data Type Specification, …])
CREATE [UNIQUE] INDEX indexName
Create new index for table; UNIQUE may be
ON tableName (field1[, field2, …])
omitted if duplicate values allowed
INSERT INTO
INSERT INTO tableName VALUES (field1
Insert full record into database; values or NULL
value[, field2 value, …])
must be present in order fields were created
UPDATE
UPDATE tableName SET column1 =
Update fields listed with new values given for
field1 newValue[, column2 = field2
records matching search condition
newValue, …] WHERE searchCondition
DELETE
DELETE FROM tableName WHERE
Delete from table records matching search
searchCondition
condition
SELECT
SELECT field1[, field2, …] FROM
Query database and return values for selected
tableName WHERE searchCondition
fields from records matching search condition
ORDER BY field1[, field2, …] [DESC]
sorted by field list; ascending is default,
descending optional
The following step enters code to establish a JDBC™ Connection and create
a Statement object.
To Establish a JDBC™ Connection
1. Enter lines 17 through 22 as shown in Figure 11-17 on page 709.
Lines 17 through 22 establish a database connection and create a
Statement object for executing SQL statements (Figure 11-20).
establish
connection
create
Statement
create
Statement object
FIGURE 11-20
 
Search WWH ::




Custom Search