Name
HANDLER
Synopsis
HANDLERtable
OPEN [AShandle
] HANDLERhandle
READindex
{ = | >= | <= | < } (value
,...) [WHEREcondition
] [LIMIT ...] HANDLERhandle
READindex
{FIRST|NEXT|PREV|LAST} [WHEREcondition
] [LIMIT ...] HANDLERhandle
READ {FIRST|NEXT} [WHEREcondition
] [LIMIT ...] HANDLERhandle
CLOSE
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 ...
Get MySQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.