首页 / MYSQL / 程序媛计划——mysql索引
程序媛计划——mysql索引
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了程序媛计划——mysql索引,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2125字,纯文字阅读大概需要4分钟。
内容图文
![程序媛计划——mysql索引](/upload/InfoBanner/zyjiaocheng/491/5aeef0538237440eaa177cea3a0ae697.jpg)
#在表中的字段中创建索引
mysql> create index ind_score on score(name); Query OK, 0 rows affected (0.03 sec) Records: 0 Duplicates: 0 Warnings: 0 #查看索引 mysql> show index from score; +-------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | +-------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | score | 0 | PRIMARY | 1 | id | A | 4 | NULL | NULL | | BTREE | | | | score | 1 | ind_score | 1 | name | A | 4 | NULL | NULL | | BTREE | | | +-------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ 2 rows in set (0.00 sec)
#也可以在创建表的时候创建索引
#删除索引
mysql> drop index ind_score on score; Query OK, 0 rows affected (0.01 sec) Records: 0 Duplicates: 0 Warnings: 0
#用alter创建/删除索引
mysql> alter table score add index ind_score(name); Query OK, 0 rows affected (0.02 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> alter table score drop index ind_score; Query OK, 0 rows affected (0.01 sec) Records: 0 Duplicates: 0 Warnings: 0
#创建索引值唯一的索引(好处是数据很多时能通过唯一索引快速查询到数据)
mysql> create unique index uni_index on score(score); Query OK, 0 rows affected (0.02 sec) Records: 0 Duplicates: 0 Warnings: 0
程序媛计划——mysql索引
标签:.com 删除索引 alter img war alt mysql code card
本文系统来源:http://www.cnblogs.com/IcarusYu/p/7497716.html
内容总结
以上是互联网集市为您收集整理的程序媛计划——mysql索引全部内容,希望文章能够帮你解决程序媛计划——mysql索引所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。