mysql索引 primary index unique fulltext 有什么区别?

lfhfut 2003-07-31 10:49:50
mysql索引 primary index unique fulltext 有什么区别?

mysql doc 上这么说:
Indexes are used to find rows with a specific value of one column fast. Without an index MySQL has to start with the first record and then read through the whole table until it finds the relevant rows. The bigger the table, the more this costs. If the table has an index for the columns in question, MySQL can quickly get a position to seek to in the middle of the datafile without having to look at all the data. If a table has 1000 rows, this is at least 100 times faster than reading sequentially. Note that if you need to access almost all 1000 rows it is faster to read sequentially because we then avoid disk seeks.

All MySQL indexes (PRIMARY, UNIQUE, and INDEX) are stored in B-trees. Strings are automatically prefix- and end-space compressed.

但是我没找到介绍PRIMARY, UNIQUE, and INDEX区别的文章,请大虾指教.
...全文
1042 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
shuixin13 2003-08-01
  • 打赏
  • 举报
回复
呵呵,

1: 等下一个版本!!
MySQL 的 FULLTEXT SEARCH TODO 中明确提出了将加强对多字节字集的支持!

2: 其它的替代办法!!
a. 对所有汉字字段不要使用 Binary ,设置默认字符集,
使用 LIKE 查询
b. 使用一些多字符安全的函数进行处理,
然后以 Binary 模式进行比较

呵呵,
没有全文索引功能可能会对某些项目应该有所影响,
不过没有什么大碍的,
相信 MySQL 会做的越来越好!
我期待着它的下一个版本!
shuixin13 2003-08-01
  • 打赏
  • 举报
回复
呵呵,

1: 等下一个版本!!
MySQL 的 FULLTEXT SEARCH TODO 中明确提出了将加强对多字节字集的支持!

2: 其它的替代办法!!
a. 对所有汉字字段不要使用 Binary ,设置默认字符集,
使用 LIKE 查询
b. 使用一些多字符安全的函数进行处理,
然后以 Binary 模式进行比较

呵呵,
没有全文索引功能可能会对某些项目应该有所影响,
不过没有什么大碍的,
相信 MySQL 会做的越来越好!
我期待着它的下一个版本!
bluemeteor 2003-08-01
  • 打赏
  • 举报
回复
又来晚了.....无出头之日了

犬犬正好问问,mysql的全文索引对中文支持不是很好,除了binary之外和改字符集还有什么好办法:)
shuixin13 2003-08-01
  • 打赏
  • 举报
回复
PRIMARY 主键,一个表中只能有一个主键,
该键值不能为 NULL ,不能重复

UNIQUE 唯一键(或称 第二辅助键),一个表中可以有多个
该键值不能重复,但是可以有多个记录值为 NULL

INDEX 普通的索引

FULLTEXT 全文索引,这在 MySQL参考手册 的第六章倒数第二节有详细的阐述
bluemeteor 2003-08-01
  • 打赏
  • 举报
回复
5702kb是primary和unique两个索引合计占用的空间


unique,index的区别是前者必须记录唯一,index可以重复取值...

fulltext是全文索引 用于like 子句
lfhfut 2003-08-01
  • 打赏
  • 举报
回复
是word表的结构,另外那个索引大小5702kb,这个索引文件是wordid的索引还是title的索引?
lfhfut 2003-08-01
  • 打赏
  • 举报
回复
字段 类型 属性 Null 缺省值 额外 执行操作
wordid int(10) UNSIGNED 否 auto_increment
title char(50) 否

键名 类型 组别 执行操作 字段
PRIMARY PRIMARY 199059 丢弃 编辑 wordid
title UNIQUE 199059 丢弃 编辑 title

类型 使用
数据 10,692 KB
索引 5,702 KB
总计 16,394 KB

上面是VB论坛中间word数据库的结构,从上面看,设置了uniqe以后也会有索引
那这样的话unique,index,fulltext三种索引方法有什么区别呢
也就是分别用在什么情况下呢?

57,065

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧