V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
? 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
wangyu1314
V2EX  ?  MySQL

如何快速查找 MySQL 数据库里哪些表没有建立索引 ?

  •  
  •   wangyu1314 · 2016-07-10 18:27:19 +08:00 · 5752 次点击
    这是一个创建于 2861 天前的主题,其中的信息可能已经有所发展或是发生改变。
    快速查找 MySQL 数据库里哪些表没有建立索引?表很多个,不要说用命令一个个地查看,我是想快速一下就了解哪些表没建索引的。
    有没有方法?谢谢各位。。
    5 条回复  ?  2016-07-11 08:18:52 +08:00
    caixiexin
        1
    caixiexin  
       2016-07-10 19:57:06 +08:00 via Android
    导出建表语句,用文本工具处理下,查找哪个表没有 index 定义?
    lenmore
        2
    lenmore  
       2016-07-10 20:50:50 +08:00   ?? 2
    SELECT * FROM information_schema.tables AS t
    LEFT JOIN (SELECT DISTINCT table_schema, table_name FROM information_schema.`KEY_COLUMN_USAGE` ) AS kt ON kt.table_schema=t.table_schema AND kt.table_name = t.table_name
    WHERE t.table_schema NOT IN ('mysql', 'information_schema', 'performance_schema', 'test') AND kt.table_name IS NULL
    wangyu1314
        3
    wangyu1314  
    OP
       2016-07-10 22:30:06 +08:00
    感谢 2 楼,不过我初学 MYSQL ,不是太懂,继续研究中,感谢。
    morewe
        4
    morewe  
       2016-07-10 22:47:41 +08:00
    phpMyAdmin 里,[数据字典] 不是可以显示出所有的表结构么。索引也显示的啊。虽然不能直接列出来哪些没见索引,但是鼠标滚动条上下滑动看看就能看出来哪个没建啊。
    bikong0411
        5
    bikong0411  
       2016-07-11 08:18:52 +08:00 via iPhone
    show index from tb
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5564 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 07:02 · PVG 15:02 · LAX 00:02 · JFK 03:02
    Developed with CodeLauncher
    ? Do have faith in what you're doing.


    http://www.vxiaotou.com