mysqlhandler语句之一-创新互联
handler语句概述
handler类似于select语句,但又不同于后者,它只能每次查询1次记录。handler有一些特殊的功能,适用于一些特定的场景。本文介绍handler语句相关的一些知识,以便后用。
襄垣网站建设公司成都创新互联,襄垣网站设计制作,有大型网站制作公司丰富经验。已为襄垣上千提供企业网站建设服务。企业网站搭建\外贸营销网站建设要多少钱,请找那个售后服务好的襄垣做网站的公司定做!联系方式
微信公众号
(微信公众号每日定期分享 欢迎大家关注)
微信
培训课件
(收费20元已共享到百度云盘便于同学们获取)
目录
handler语句官方手册
handler语句语法
handler语句示例
handler语句适用场景
handler语句注意事项
handler语句官方手册
13 SQL Statement Syntax 13.2 Data Manipulation Statements 13.2.4 HANDLER Syntax
handler语句语法
HANDLER tbl_name OPEN [ [AS] alias] HANDLER tbl_name READ index_name { = | <= | >= | < | > } (value1,value2,...) [ WHERE where_condition ] [LIMIT ... ] HANDLER tbl_name READ index_name { FIRST | NEXT | PREV | LAST } [ WHERE where_condition ] [LIMIT ... ] HANDLER tbl_name READ { FIRST | NEXT } [ WHERE where_condition ] [LIMIT ... ] HANDLER tbl_name CLOSE
handler语句示例
为handle指定一个别名用于使用多个handle
HANDLER tbl_name OPEN [ [AS] alias]
mysql> handler t_table_lock open p1; Query OK, 0 rows affected (0.00 sec)
打开表和关闭表
HANDLER tbl_name OPEN [ [AS] alias] HANDLER tbl_name CLOSE
mysql> handler t_table_lock open; Query OK, 0 rows affected (0.00 sec) mysql> show open tables from zxydb like 't_table_lock'; +----------+--------------+--------+-------------+ | Database | Table | In_use | Name_locked | +----------+--------------+--------+-------------+ | zxydb | t_table_lock | 1 | 0 | +----------+--------------+--------+-------------+ 1 row in set (0.00 sec) mysql> handler t_table_lock close; Query OK, 0 rows affected (0.00 sec) ## mysql> show open tables from zxydb like 't_table_lock'; +----------+--------------+--------+-------------+ | Database | Table | In_use | Name_locked | +----------+--------------+--------+-------------+ | zxydb | t_table_lock | 0 | 0 | +----------+--------------+--------+-------------+ 1 row in set (0.00 sec)
读取表的记录
HANDLER tbl_name READ { FIRST | NEXT } [ WHERE where_condition ] [LIMIT ... ]
##获取表第1条记录 mysql> handler t_table_lock read first; +------+------+ | a | b | +------+------+ | 1 | 1 | +------+------+ 1 row in set (0.00 sec) ##获取表的下一条记录 mysql> handler t_table_lock read next; Empty set (0.00 sec)
获取指定索引值的表记录
HANDLER tbl_name READ index_name { = | <= | >= | < | > } (value1,value2,...) [ WHERE where_condition ] [LIMIT ... ]
mysql> handler t_table_lock read idx_a=(1); +------+------+ | a | b | +------+------+ | 1 | 1 | +------+------+ 1 row in set (0.00 sec) ## mysql> handler t_table_lock read idx_a=(2); Empty set (0.00 sec)
获取指定索引的第一,下一,前一,最后的表记录
HANDLER tbl_name READ index_name { FIRST | NEXT | PREV | LAST } [ WHERE where_condition ] [LIMIT ... ]
## mysql> handler t_table_lock read idx_a first; +------+------+ | a | b | +------+------+ | 1 | 1 | +------+------+ 1 row in set (0.00 sec) ## mysql> handler t_table_lock read idx_a next; Empty set (0.00 sec) ## mysql> handler t_table_lock read idx_a last; +------+------+ | a | b | +------+------+ | 1 | 1 | +------+------+ 1 row in set (0.00 sec) ## mysql> handler t_table_lock read idx_a prev; Empty set (0.00 sec)
handler语句适用场景
handler语句注意事项
网页名称:mysqlhandler语句之一-创新互联
本文网址:http://ybzwz.com/article/dsepjd.html