background image
<< Statement dependency system | GROUP BY clause >>

FOR UPDATE clause

<< Statement dependency system | GROUP BY clause >>
Derby Reference Manual
81
If a constraint-Name is not specified, Derby generates a unique constraint name (for
either column or table constraints).
FOR UPDATE clause
The FOR UPDATE clause is an optional part of a
SELECT statement
. Cursors are
read-only by default. The FOR UPDATE clause specifies that the cursor should be
updatable, and enforces a check during compilation that the SELECT statement meets
the requirements for an updatable cursor. For more information about updatability, see
Requirements for updatable cursors and updatable ResultSets
.
Syntax
FOR
{
READ ONLY | FETCH ONLY |
UPDATE [ OF
Simple-column-Name
[ ,
Simple-column-Name
]* ]
}
Simple-column-Name refers to the names visible for the table specified in the FROM
clause of the underlying query.
Note: The use of the FOR UPDATE clause is not mandatory to obtain an
updatable JDBC ResultSet. As long as the statement used to generate the JDBC
ResultSet meets the requirements for updatable cursor, it is sufficient for the
JDBC Statement that generates the JDBC ResultSet to have concurrency mode
ResultSet.CONCUR_UPDATABLE
for the ResultSet to be updatable.
The optimizer is able to use an index even if the column in the index is being updated.
For information about how indexes affect performance, see Tuning Derby.
Example
SELECT RECEIVED, SOURCE, SUBJECT, NOTE_TEXT FROM SAMP.IN_TRAY FOR UPDATE
FROM clause
The FROM clause is a mandatory clause in a
SelectExpression
. It specifies the tables
(
TableExpression
) from which the other clauses of the query can access columns for use
in expressions.
Syntax
FROM TableExpression [ , TableExpression ] *
Examples
SELECT Cities.city_id
FROM Cities
WHERE city_id < 5
-- other types of TableExpressions
SELECT TABLENAME, ISINDEX
FROM SYS.SYSTABLES T, SYS.SYSCONGLOMERATES C
WHERE T.TABLEID = C.TABLEID
ORDER BY TABLENAME, ISINDEX
-- force the join order
SELECT *
FROM Flights, FlightAvailability
WHERE FlightAvailability.flight_id = Flights.flight_id
AND FlightAvailability.segment_number = Flights.segment_number
AND Flights.flight_id < 'AA1115'
-- a TableExpression can be a joinOperation. Therefore
-- you can have multiple join operations in a FROM clause