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
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
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
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