• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

mysql索引类型介绍

mysql 搞代码 4年前 (2022-01-09) 16次浏览 已收录 0个评论

索引类型介绍:

主键索引

primary key() 要求关键字不能重复,也不能为null,同时增加主键约束 主键索引定义时,不能命名

唯一索引

unique index() 要求关键字不能重复,同时增加唯一约束

普通索引

index() 对关键字没有要求

全文索引

fulltext key() 关键字的来源不是所有字段的数据,而是字段中提取的特别关键字

关键字:可以是某个字段或多个字段,多个字段称为复合索引。

实例:

建表:creat table student(    stu_id int unsigned not null auto_increment,    name varchar(32) not null default '',    phone char(11) not null default '',    stu_code varchar(32) not null default '',    stu_desc text,    primary key ('stu_id'),     //主键索引    unique index 'stu_code' ('stu_code'), //唯一索引    index 'name_phone' ('name','phone'),  //普通索引,复合索引    fulltext index 'stu_desc' ('stu_desc'), //全文索引) engine=myisam charset=utf8;更新:alert table student    add primary key ('stu_id'),     //主键索引    add unique index 'stu_code' ('stu_cod<div style="color:transparent">本文来源gaodai^.ma#com搞#代!码网</div>e'), //唯一索引    add index 'name_phone' ('name','phone'),  //普通索引,复合索引    add fulltext index 'stu_desc' ('stu_desc'); //全文索引删除:alert table sutdent    drop primary key,    drop index 'stu_code',    drop index 'name_phone',    drop index 'stu_desc';

以上就是mysql索引类型介绍的详细内容,更多请关注搞代码gaodaima其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:mysql索引类型介绍

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址