Name
HANDLER
Synopsis
HANDLERtableOPEN [AShandle] HANDLERhandleREADindex{ = | >= | <= | < } (value,...) [WHEREcondition] [LIMIT ...] HANDLERhandleREADindex{FIRST|NEXT|PREV|LAST} [WHEREcondition] [LIMIT ...] HANDLERhandleREAD {FIRST|NEXT} [WHEREcondition] [LIMIT ...] HANDLERhandleCLOSE
A handle provides direct access to a table, as opposed to
working from a results set. Handles can be faster than
SELECT statements when reading large numbers of
rows from a table. MyISAM and InnoDB tables currently support
handlers.
A handle is usable only by the session (connection thread) that established it. The table is still accessible by other sessions, though, and is not locked by this statement. Because of this, and because the method provides direct table access, the data in the table can change and even be incomplete as the handler performs successive reads.
Create a handler by issuing a HANDLER
statement with the OPEN clause to establish a
handle for the table, much like a file handle in a programming
language such as Perl. The AS clause and handle
name are optional. If an alias is not given, the table name is used as
the handler name for subsequent HANDLER
statements.
You can then use HANDLER statement formats
with READ clauses to read data from a
table. Finish by issuing HANDLER with a
CLOSE clause.
Here are a couple of basic examples of the
HANDLER statement:
HANDLER clients OPEN AS clients_handle; HANDLER clients_handle READ FIRST;
The first line creates the table handle called ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access