在Mysql中使用索引排序的方法首先,在命令行中启动mysql服务;service mysql start MySQL服务启动后,在命令行中输入mysql的用户名和密码登录到MySQL;mysql -u root -p登录到MySQL后,
首先,在命令行中启动mysql服务;
service mysql start
MySQL服务启动后,在命令行中输入mysql的用户名和密码登录到MySQL;
mysql -u root -p
登录到MySQL后,选择使用一个数据库,并在数据库中执行以下命令对索引进行排序;
use mysql;
mExplain select name, founded from artist where name like 'AUSTRALIA%' order by name \G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: artist
type: range
possible_keys: name
key: name
key_len: 257
ref: NULL
rows: 22
Extra: Using index condition
1 row in set (0.00 sec)
对索引进行排序后,重新查看表结构,即可看到索引排序的效果;
mysql> show session status like '%sort%';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| Sort_merge_passes | 0 |
| Sort_range | 0 |
| Sort_rows | 0 |
| Sort_scan | 0 |
+-------------------+-------+
4 rows in set (0.00 sec)
mysql> select name, founded from artist where name like 'AUSTRALIA%' order by name \G
......
22 rows in set (0.00 sec)
mysql> show session status like '%sort%';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| Sort_merge_passes | 0 |
| Sort_range | 0 |
| Sort_rows | 0 |
| Sort_scan | 0 |
+-------------------+-------+
4 rows in set (0.00 sec)
--结束END--
本文标题: Mysql如何使用索引排序
本文链接: https://www.lsjlt.com/news/116410.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-04-28
2024-04-28
2024-04-28
2024-04-28
2024-04-28
2024-04-28
2024-04-28
2024-04-28
2024-04-28
2024-04-28
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0