您的位置:首页 > 产品设计 > UI/UE

MySQL数据库表的主键到底是用GUID好,还是INT好?

2011-12-29 18:00 316 查看
MySQLHTML

待补充

两遍对比的文章:

http://krow.livejournal.com/497839.html

http://www.mysqlperformanceblog.com/2007/03/13/to-uuid-or-not-to-uuid/

CREATE TABLE Test_Guid

(

Guid varchar(50) not null,

TestId int not null,

TestText ntext not null,

TestDateTime datetime default getdate(),

CONSTRAINT PK_Guid PRIMARY KEY (Guid)

)

应该改成这样吧:

CREATE TABLE Test_Guid

(

Guid uniqueidentifier not null,

TestId int not null,

TestText ntext not null,

TestDateTime datetime default getdate(),

CONSTRAINT PK_Guid PRIMARY KEY (Guid)

)

另外,在使用Guid类型作为主键时,一定要记得取消主键的“聚集索引” 否则,在插入数据的时候会有严重的性能损耗。因为Guid的值不具有可预测性。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: