Java Reference
In-Depth Information
•The WHERE and ORDER BY clauses can be combined in one query. If used, ORDER BY must be the
last clause in the query.
Section 24.4.4 Merging Data from Multiple Tables: INNER JOIN
•An INNER JOIN (p. 1057) merges rows from two tables by matching values in columns that are
common to the tables. The basic form for the INNER JOIN operator is:
SELECT columnName1 , columnName2 , …
FROM table1
INNER JOIN table2
ON table1 . columnName = table2 . columnName
The ON clause (p. 1057) specifies the columns from each table that are compared to determine
which rows are joined. If a SQL statement uses columns with the same name from multiple ta-
bles, the column names must be fully qualified (p. 1057) by prefixing them with their table
names and a dot ( . ).
Section 24.4.5 INSERT Statement
•An INSERT statement (p. 1058) inserts a new row into a table. The basic form of this statement is
INSERT INTO tableName ( columnName1 , columnName2 , , columnNameN )
VALUES ( value1 , value2 , , valueN )
where tableName is the table in which to insert the row. The tableName is followed by a comma-
separated list of column names in parentheses. The list of column names is followed by the SQL
keyword VALUES (p. 1058) and a comma-separated list of values in parentheses.
• SQL uses single quotes ( ' ) to delimit strings. To specify a string containing a single quote in
SQL, escape the single quote with another single quote (i.e., '' ).
Section 24.4.6 UPDATE Statement
•An UPDATE statement (p. 1059) modifies data in a table. The basic form of an UPDATE statement is
UPDATE tableName
SET columnName1 = value1 , columnName2 = value2 , , columnNameN = valueN
WHERE criteria
where tableName is the table to update. Keyword SET (p. 1059) is followed by a comma-separated
list of columnName = value pairs. The optional WHERE clause determines which rows to update.
Section 24.4.7 DELETE Statement
•A DELETE statement (p. 1060) removes rows from a table. The simplest form for a DELETE state-
ment is
DELETE FROM tableName WHERE criteria
where tableName is the table from which to delete a row (or rows). The optional WHERE criteria
determines which rows to delete. If this clause is omitted, all the table's rows are deleted.
Section 24.5 Setting up a Java DB Database
• Oracle's pure Java database Java DB (p. 1060) is installed with the JDK on Windows, Mac OS
X and Linux.
• Java DB has both an embedded version and a network version.
• The Java DB software is located in the db subdirectory of your JDK's installation directory.
• Java DB comes with several files that enable you to configure and run it. Before executing these
files from a command window, you must set the environment variable JAVA_HOME to refer to the
JDK's exact installation directory.
Search WWH ::




Custom Search