星空网 > 软件开发 > 数据库

mysql索引之唯一索引

  mysql 的唯一索引一般用于不重复的字段,一般会把表中的id设为唯一索引,创建唯一索引的目的不是为了提高查询速度,而是为了避免数据重复,注意:唯一索引可以有多个,但是列值必须唯一,创建唯一索引使用关键字unique。

  创建唯一索引

1,创建表的时候创建索引:

create table temp2(id int(10) not null auto_increment,title varchar(10) not null,cnt int(10) not null,primary key(`id`),index(`title`),unique key cnt(`cnt`)) engine=myisam;

 

2,添加索引

  

create unique index title on article(`title`);

3,

alter table article add index content(`content`);

 

主键索引是特殊的唯一索引




原标题:mysql索引之唯一索引

关键词:MYSQL

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

1月1日起,马来西亚将对进口低价值商品征收10%销售税:https://www.kjdsnews.com/a/1692262.html
Coupang以5亿美元收购奢品电商Farfetch:https://www.kjdsnews.com/a/1692263.html
DTC智能穿戴设备品牌Noise获A轮融资:https://www.kjdsnews.com/a/1692264.html
ACOS很高应从哪些方面找原因?又该如何降低?:https://www.kjdsnews.com/a/1692265.html
关键词广告排名提升了,但自然排名却没有提升的解决方法:https://www.kjdsnews.com/a/1692266.html
受征税新政影响,10月份巴西跨境网购额下降54.5%:https://www.kjdsnews.com/a/1692267.html
淘宝给商家发了个“大红包” :https://www.kjdsnews.com/a/1836561.html
厦门曾厝垵家庭旅馆哪家最好?:https://www.vstour.cn/a/365183.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流