根据MySQL内容的长度在MySQL列上创建索引? [英] Create an index on a MySQL column based on the length its contents?

查看:177
本文介绍了根据MySQL内容的长度在MySQL列上创建索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在MySQL v 5.0(myisam数据库引擎)中根据其值的长度创建索引,其TEXT数据类型最多为7000个字符,是否必须添加另一列长度为第一列?

How do I create an index on a column in MySQL v 5.0 (myisam db engine) based upon the length of its value its a TEXT data type up to 7000 characters, do I have to add another column with the length of the first column?

推荐答案

是的,因为MySQL不支持基于函数的索引(如 ADD INDEX myIndex(LENGTH(text))),你需要一个新的int列并定义一个触发以在插入和更新后自动更新它。

Yes, as MySQL doesn't support function-based indexes (like ADD INDEX myIndex(LENGTH(text))), you'll need a new int column and define a trigger to auto-update it after inserts and updates.

这篇关于根据MySQL内容的长度在MySQL列上创建索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆