mysql> alter table info add index(age);
Query OK, 0 rows affected (0.11 sec)
Records: 0 Duplicates: 0 Warnings: 0
查看table索引:
mysql> show index from info;
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| info | 1 | age | 1 | age | A | 5 | NULL | NULL | YES | BTREE | | |
| info | 1 | age_2 | 1 | age | A | 5 | NULL | NULL | YES | BTREE | | |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
2 rows in set (0.00 sec)
create table info:
mysql> handler info read first;
+------+------+
| name | age |
+------+------+
| lisa | 27 |
+------+------+
1 row in set (0.00 sec)
mysql> handler info read next;
+------+------+
| name | age |
+------+------+
| tina | 25 |
+------+------+
1 row in set (0.00 sec)
mysql> handler info read age=(25);
+------+------+
| name | age |
+------+------+
| tina | 25 |
+------+------+
1 row in set (0.00 sec)
mysql> handler info read age=(25) limit 2;
+------+------+
| name | age |
+------+------+
| tina | 25 |
| do | 25 |
+------+------+
2 rows in set (0.00 sec)
mysql> handler info read age=(27) limit 3;
+-------+------+
| name | age |
+-------+------+
| lisa | 27 |
| ricky | 27 |
| lover | 27 |
+-------+------+
3 rows in set (0.00 sec)
mysql> handler info close;
Query OK, 0 rows affected (0.00 sec)