在MySQL中是否可以有基于函数的索引?
在低于5.6的MySQL版本中,无法使用基于函数的索引。首先,要在MySQL中创建基于函数的索引,我们将创建一个表。
mysql> create table FunctionIndexDemo - > ( - > FirstName varchar(100) - > );
让我们看看创建基于函数的索引的语法。
create index index_name on yourTableName (column_name(IntegerSize));
这是查询。
mysql> create index indFirstName on FunctionIndexDemo (FirstName(6)); Records: 0 Duplicates: 0 Warnings: 0
检查索引是否存在。
mysql> SHOW INDEX FROM FunctionIndexDemo;
这是输出。
+-------------------+------------+--------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | +-------------------+------------+--------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+ | functionindexdemo | 1 | indFirstName | 1 | FirstName | A | 0 | 6 | NULL | YES | BTREE | | | YES | +-------------------+------------+--------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+ 1 row in set (0.24 sec)
热门推荐
10 新年门口花束祝福语简短
11 盘锦结婚祝福语大全简短
12 父母生日祝福语 简短独特
13 家庭恩爱祝福语简短英文
14 高考俄语祝福语大全简短
15 虎年祝福语 诗句唯美简短
16 生日婚礼祝福语简短精辟
17 虎年喝酒拜年祝福语简短
18 教师闺蜜祝福语简短