关于mysql的聚簇索引,请教!

yufulou 2011-11-10 05:21:09
看了文档:
http://database.51cto.com/art/201005/202820.htm
http://hi.baidu.com/jackywdx/blog/item/516daafc02360af9fd037f19.html

现在有三个问题:
innodb是会自动把主键索引建立成聚簇索引的,如果没有主键,会找一个唯一值,如果没有,会自建一个隐藏主键当做聚簇索引的,对吗?
执行“CREATE CLUSTERED INDEX mycolumn_cindex ON mytable(mycolumn) WITH ALLOW_DUP_ROW”,这句话的话,是会把原来的聚簇索引取消掉,整个表空间按mycolumn的顺序重排吗?
如果本来没有主键的话,那么,重新设置聚簇索引后,那个隐藏主键会自动被删除掉吗?
...全文
85 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
yufulou 2011-11-10
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 acmain_chm 的回复:]

引用执行“CREATE CLUSTERED INDEX mycolumn_cindex ON mytable(mycolumn) WITH ALLOW_DUP_ROW”,这句话的话,MYSQL中有这个语法吗? 你的MYSQL的版本是多少?
[/Quote]

多些老大提醒,我是看那个帖子里说的,google里都没查着有这么用的……貌似被那个帖子忽悠了……
结贴给分了~~
ACMAIN_CHM 2011-11-10
  • 打赏
  • 举报
回复
[Quote]执行“CREATE CLUSTERED INDEX mycolumn_cindex ON mytable(mycolumn) WITH ALLOW_DUP_ROW”,这句话的话,[/Quote]MYSQL中有这个语法吗? 你的MYSQL的版本是多少?
ACMAIN_CHM 2011-11-10
  • 打赏
  • 举报
回复
[Quote]innodb是会自动把主键索引建立成聚簇索引的,如果没有主键,会找一个唯一值,如果没有,会自建一个隐藏主键当做聚簇索引的,对吗?[/Quote]


[Quote]
13.6.10.1. Clustered and Secondary Indexes
Every InnoDB table has a special index called the clustered index where the data for the rows is stored:

If you define a PRIMARY KEY on your table, InnoDB uses it as the clustered index.

If you do not define a PRIMARY KEY for your table, MySQL picks the first UNIQUE index that has only NOT NULL columns as the primary key and InnoDB uses it as the clustered index.

If the table has no PRIMARY KEY or suitable UNIQUE index, InnoDB internally generates a hidden clustered index on a synthetic column containing row ID values. The rows are ordered by the ID that InnoDB assigns to the rows in such a table. The row ID is a 6-byte field that increases monotonically as new rows are inserted. Thus, the rows ordered by the row ID are physically in insertion order.

[/Quote]

56,677

社区成员

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

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