【问题标题】:#1170 - BLOB/TEXT column 'question_content' used in key specification without a key length#1170 - 密钥规范中使用的 BLOB/TEXT 列“question_content”没有密钥长度
【发布时间】:2020-03-27 01:58:03
【问题描述】:
ALTER TABLE `aws_testquestion`
  ADD PRIMARY KEY (`question_id`),
  ADD KEY `category_id` (`category_id`),
  ADD KEY `update_time` (`update_time`),
  ADD KEY `add_time` (`add_time`),
  ADD KEY `published_uid` (`published_uid`),
  ADD KEY `answer_count` (`answer_count`),
  ADD KEY `agree_count` (`agree_count`),
  ADD KEY `question_content` (`question_content`),
  ADD KEY `lock` (`lock`),
  ADD KEY `thanks_count` (`thanks_count`),
  ADD KEY `anonymous` (`anonymous`),
  ADD KEY `popular_value` (`popular_value`),
  ADD KEY `best_answer` (`best_answer`),
  ADD KEY `popular_value_update` (`popular_value_update`),
  ADD KEY `against_count` (`against_count`),
  ADD KEY `is_recommend` (`is_recommend`),
  ADD KEY `weibo_msg_id` (`weibo_msg_id`),
  ADD KEY `received_email_id` (`received_email_id`),
  ADD KEY `unverified_modify_count` (`unverified_modify_count`),
  ADD KEY `chapter_id` (`chapter_id`),
  ADD KEY `sort` (`sort`[...]

我收到了这个错误:

#1170 - BLOB/TEXT column 'question_content' used in key specification without a key length

【问题讨论】:

  • question_content 的数据类型是什么? PHP是如何相关的?似乎是mysql 问题。可能您需要查看的是dba.stackexchange.com/questions/210403/… 如果这是您在这里所做的,您也不应该只索引表上的每一列。
  • 好的,谢谢你的回答我现在明白了

标签: mysql indexing database-design


【解决方案1】:
  • 出于多种原因,“为每一列编制索引”是一种不好的做法。
  • TEXTBLOB 不能被索引,除非使用“前缀”索引,这很少有用。
  • 索引真/假列很少有帮助。
  • 最好根据流行的SELECTs设计索引。向我们展示其中的一些。
  • 一个表可以处理多少索引是有限制的。 (很少有超过 5 个的实际情况。硬限制是 64 个。)

【讨论】:

    猜你喜欢
    • 2019-01-05
    • 2012-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-22
    相关资源
    最近更新 更多