Choose partial key in table creation : Key « Table « MySQL Tutorial






mysql>
mysql>
mysql> CREATE TABLE Employee (
    ->   last_name VARCHAR(30) NOT NULL,
    ->   KEY lastname_idx (last_name(3))
    -> );
Query OK, 0 rows affected (0.03 sec)

mysql>
mysql> SHOW KEYS FROM Employee;
+----------+------------+--------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table    | Non_unique | Key_name     | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+----------+------------+--------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Employee |          1 | lastname_idx |            1 | last_name   | A         |        NULL |        3 | NULL   |      | BTREE      |         |
+----------+------------+--------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
1 row in set (0.00 sec)

mysql>
mysql> drop table Employee;
Query OK, 0 rows affected (0.02 sec)

mysql>
mysql>








4.14.Key
4.14.1.Multiple-Column Keys
4.14.2.Partial Keys
4.14.3.Choose partial key in table creation
4.14.4.Composite Partial Keys
4.14.5.SHOW KEYS FROM Employee Table
4.14.6.ALTER TABLE Employee DROP KEY lastn_idx;