| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
HANDLER Syntax
HANDLER tbl_name OPEN [ AS alias ]
HANDLER tbl_name READ index_name { = | >= | <= | < } (value1,value2,...)
[ WHERE ... ] [LIMIT ... ]
HANDLER tbl_name READ index_name { FIRST | NEXT | PREV | LAST }
[ WHERE ... ] [LIMIT ... ]
HANDLER tbl_name READ { FIRST | NEXT }
[ WHERE ... ] [LIMIT ... ]
HANDLER tbl_name CLOSE
|
The HANDLER statement provides direct access to the MyISAM table
storage engine interface.
The first form of HANDLER statement opens a table, making
it accessible via subsequent HANDLER ... READ statements.
This table object is not shared by other threads and will not be closed
until the thread calls HANDLER tbl_name CLOSE or the thread dies.
The second form fetches one row (or more, specified by LIMIT
clause) where the index specified satisfies the given values and the
WHERE condition is met. If you have a multiple-column index,
specify the index column values as a comma-separated list. Either specify
values for all the columns in the index, or specify values for a leftmost
prefix of the index columns. Suppose an index includes three columns
named col_a, col_b, and col_c, in that order.
The HANDLER statement can specify values for all three columns in the
index, or for the columns in a leftmost prefix. For example:
HANDLER ... index_name = (col_a_val,col_b_val,col_c_val) ... HANDLER ... index_name = (col_a_val,col_b_val) ... HANDLER ... index_name = (col_a_val) ... |
The third form fetches one row (or more, specified by LIMIT clause)
from the table in index order, matching WHERE condition.
The fourth form (without index specification) fetches one row (or more, specified
by LIMIT clause) from the table in natural row order (as stored
in datafile) matching WHERE condition. It is faster than
HANDLER tbl_name READ index_name when a full table scan is desired.
HANDLER ... CLOSE closes a table that was opened with
HANDLER ... OPEN.
Note: If you're using HANDLER interface for PRIMARY KEY you should
remember to quote the keyword PRIMARY with backticks:
HANDLER tbl READ `PRIMARY` > (...)
HANDLER is a somewhat low-level statement. For example, it does
not provide consistency. That is, HANDLER ... OPEN does NOT
take a snapshot of the table, and does NOT lock the table. This
means that after a HANDLER ... OPEN is issued, table data can be
modified (by this or any other thread) and these modifications may appear
only partially in HANDLER ... NEXT or HANDLER ... PREV scans.
The reasons to use this interface instead of normal SQL are:
SELECT because:
HANDLER OPEN.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |