mysql索引
来源:互联网 发布:linux下运行jar包 编辑:程序博客网 时间:2024/06/10 02:20
1、创建表时创建索引
[UNIQUE|FULLINDEX] index|KEY [别名](属性名[长度][ASC|DESC])
mysql> create table test1(
-> id int(10),
-> name varchar(20),
-> index(id) /unique key uid(id)唯一索引
-> );
2、在现有表上创建索引
create [unique|fulltext] index 索引名 on 表名(属性名)
create unique index uid on ts(id)
alter table b add unique index uid(id)
查看索引是否被使用:
不带条件的查询未使用索引
explain select * from test\G;
仅按索引字段排序的查询未使用索引
explain select * from test order by id asc\G;
*带有索引字段查询条件的查询使用了索引
explain select * from test where id=1\G;
查看索引
show index from table_name
删除索引
alter table table_name drop index index_name
删除主键约束
alter table test drop primary key;
[UNIQUE|FULLINDEX] index|KEY [别名](属性名[长度][ASC|DESC])
mysql> create table test1(
-> id int(10),
-> name varchar(20),
-> index(id) /unique key uid(id)唯一索引
-> );
2、在现有表上创建索引
create [unique|fulltext] index 索引名 on 表名(属性名)
create unique index uid on ts(id)
alter table b add unique index uid(id)
查看索引是否被使用:
不带条件的查询未使用索引
explain select * from test\G;
仅按索引字段排序的查询未使用索引
explain select * from test order by id asc\G;
*带有索引字段查询条件的查询使用了索引
explain select * from test where id=1\G;
查看索引
show index from table_name
删除索引
alter table table_name drop index index_name
删除主键约束
alter table test drop primary key;
0 0
- MySQL索引 聚集索引
- mysql 索引 & 索引类型
- MySQL索引 聚集索引
- mysql 索引 & 索引类型
- mysql索引
- mysql索引
- mysql 索引
- MySql索引
- Mysql索引
- mysql 索引
- mysql 索引
- MySQL索引
- mysql索引
- mysql 索引
- mysql索引
- mysql 索引
- MySQL索引
- mysql索引
- 语音的Mfcc特征学习与理解
- java类的继承
- POJ 1517 u Calculate e
- hdoj 2064 汉诺塔III
- Python性能分析指南
- mysql索引
- 电池充电时扩散页面动画效果相关
- MySQL Windows ZIP 免安装版的设置和启动
- swap
- google 著名技术
- 如何用笔记本建立虚拟wifi(新手教程)
- hdu 1247 字典树模版
- 国外程序员整理的 C++ 资源大全
- for循环内变量定义问题