I*****y 发帖数: 6402 | 1 在建mysql数据库table的时候,因为read这个表格多于insert, 想弄一个index, 根据我
现在的理解就是设置primary key, 请问这样理解对吗? | B*****g 发帖数: 34098 | 2 http://dev.mysql.com/doc/refman/5.0/en/mysql-indexes.html
据我
【在 I*****y 的大作中提到】 : 在建mysql数据库table的时候,因为read这个表格多于insert, 想弄一个index, 根据我 : 现在的理解就是设置primary key, 请问这样理解对吗?
| j*****n 发帖数: 1781 | 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. | w*******e 发帖数: 1622 | 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.
| j*****n 发帖数: 1781 | 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.
| u******u 发帖数: 595 | 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 |
|