› MySQL 5.5 Community Server
› MySQL 5.6 Community Server
› Percona Configuration Wizard
› XtraBackup 搭建主从复制
Great Sites on MySQL
› Percona
› MySQL Performance Blog
› Severalnines
推荐管理工具
› Sequel Pro
› phpMyAdmin
推荐书目
› MySQL Cookbook
MySQL 相关项目
› MariaDB
› Drizzle
参考文档
› http://mysql-python.sourceforge.net/MySQLdb.html
rogwan
V2EX  ›  MySQL

MySQL 为什么不能删除( drop)索引( index)?

  •  
  •   rogwan · Dec 22, 2016 · 5833 views
    This topic created in 3564 days ago, the information mentioned may be changed or developed.

    class Student(db.Model):

    tablename = 'students'
    id = db.Column(db.Integer, primary_key=True)
    student_name = db.Column(db.String(32), index=True)

    mysql> alter table students drop index student_name;

    提示错误: ERROR 1091 ( 42000 ): can't drop 'student_name'; check that column/key exists

    用 show index from students 看了,明明 student_name 有加索引啊,怎么去除 drop 不掉呢?(考虑到有会有很多名字重复,就不加索引了)

    2 replies  •  2016-12-23 11:18:09 +08:00
    nomaka
        1
    nomaka  
       Dec 22, 2016   ❤️ 1
    show index from students 你要看 key name 是啥 你要删索引的名字 不是 字段的名字啊
    rogwan
        2
    rogwan  
    OP
       Dec 23, 2016
    @nomaka 那个是系统自动生成的 key_name 是 ix_students_student_name ,开始没敢删 -:)
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   955 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 18:40 · PVG 02:40 · LAX 11:40 · JFK 14:40
    ♥ Do have faith in what you're doing.