在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 收生日红包祝福语 简短