mysqlhandler语句之一
handler语句概述
handler类似于select语句,但又不同于后者,它只能每次查询1次记录。handler有一些特殊的功能,适用于一些特定的场景。本文介绍handler语句相关的一些知识,以便后用。
成都创新互联公司-专业网站定制、快速模板网站建设、高性价比武江网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式武江网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖武江地区。费用合理售后完善,10年实体公司更值得信赖。
联系方式
微信公众号
(微信公众号每日定期分享 欢迎大家关注)
微信
培训课件
(收费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://scyanting.com/article/gcpgoc.html