Redian新闻
>
indexing就是设置primary key吗?
avatar
indexing就是设置primary key吗?# Database - 数据库
I*y
1
在建mysql数据库table的时候,因为read这个表格多于insert, 想弄一个index, 根据我
现在的理解就是设置primary key, 请问这样理解对吗?
avatar
B*g
2
http://dev.mysql.com/doc/refman/5.0/en/mysql-indexes.html

据我

【在 I*****y 的大作中提到】
: 在建mysql数据库table的时候,因为read这个表格多于insert, 想弄一个index, 根据我
: 现在的理解就是设置primary key, 请问这样理解对吗?

avatar
j*n
3
not sure for mysql, but for MSSQL, if you specify a primary key, it will
automatically create a clustered index for you.
anyway, indexing is different thing with your PK...
get your knowledge updated by read some database fundamental books please.
avatar
w*e
4
准确的说是: 如果没clustered Index, 那么it will automatically create a
clustered index on the PK for you.
如果有个clustered index 存在了, 那就是automatically create a non-clustered
index on that PK for you.

【在 j*****n 的大作中提到】
: not sure for mysql, but for MSSQL, if you specify a primary key, it will
: automatically create a clustered index for you.
: anyway, indexing is different thing with your PK...
: get your knowledge updated by read some database fundamental books please.

avatar
j*n
5
en, maybe you right, I just suppose that lz's table has no PK and indexes
yet.
btw, you can specify do not create clustered index for PK by default. it was
critical issue for MSSQL 6.5 when creating highly transactional OLTP. e.g.
1,000 inserts/second. it will cause "hotspot" problem when PK with clustered
index.
of course, it is already the history, just mention it for fun. :)
when you see some DB under such scenario, you can say, ha, it was originally
created under 6.5 version!

【在 w*******e 的大作中提到】
: 准确的说是: 如果没clustered Index, 那么it will automatically create a
: clustered index on the PK for you.
: 如果有个clustered index 存在了, 那就是automatically create a non-clustered
: index on that PK for you.

avatar
u*u
6
For any relational database (Oracle, MS SQL, MySQL, DB2...):
Primary key is a table constraint, it means Unique and NOT NULL.
alter table T add primary key (id); will create a primary key on id column,
in the meantime, it will also creat a uniq index on that id column.
You can create a unique index for id column on table T as below:
create unique index idx_t on t(id);
However, unique index column can be NULL.
Therefore, Unix index doesn't equal to primary key.
Send me email for more database q
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。