用于PK的数据类型是什么? [英] What datatype to use for PK?

查看:124
本文介绍了用于PK的数据类型是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

多年来,我一直使用小数(18,0)作为

主键的数据类型。除了涉及的重要数字的数量,

BigInt类型的性能会更好,或者十进制(18,0)仍然可以。

-

Don Vaillancourt

软件开发总监

WEB IMPACT INC。

电话:416-815-2000转。 245

传真:416-815-2001

电子邮件:执行** @ web- impact.com < mailto:do ** @ webimpact.com>

web: http://www.web-impact.com
Web Impact Inc.< http://www.web-impact.com>

此电子邮件仅供收信人使用,并包含可能保密和/或版权的

信息。


如果您不是预定的收件人,请通过回复通知发件人

电子邮件并立即删除此电子邮件。


任何人使用,披露或复制此电子邮件除了

预定的收件人是严格禁止的。没有任何陈述

此电子邮件或任何附件没有病毒。病毒扫描

建议由接收者负责。

Over the years I have always used the decimal(18,0) as the datatype for
primary keys. Aside from the number of significant numbers involved,
would BigInt type be better for performance or is decimal(18,0) still okay.
--
Don Vaillancourt
Director of Software Development
WEB IMPACT INC.
phone: 416-815-2000 ext. 245
fax: 416-815-2001
email: do**@web-impact.com <mailto:do**@webimpact.com>
web: http://www.web-impact.com
Web Impact Inc. <http://www.web-impact.com>
This email message is intended only for the addressee(s) and contains
information that may be confidential and/or copyright.

If you are not the intended recipient please notify the sender by reply
email and immediately delete this email.

Use, disclosure or reproduction of this email by anyone other than the
intended recipient(s) is strictly prohibited. No representation is made
that this email or any attachments are free of viruses. Virus scanning
is recommended and is the responsibility of the recipient.

推荐答案

BIGINT比DECIMAL小一个字节( 18,0)。 8字节与9

字节。


除非你在说话,否则不太可能显着改变性能

百万行正在处理。

BIGINT is stored one byte smaller than DECIMAL(18,0). 8 bytes vs. 9
bytes.

Not likely to significantly change performance unless you''re talking
millions of rows being processed.


我一直认为小数以文本格式存储它的值。因此,对于

十进制(18,0),MSSQL将占用18个字节。或者我部分正确并且

MSSQL使用半字节来表示数字。


Gary写道:
I always thought that decimal stored it''s values in text format. So for
decimal(18,0) MSSQL would take up 18 bytes. Or am I partially right and
MSSQL uses a nibble to represent a digit.

Gary wrote:
BIGINT存储一个字节小于DECIMAL(18,0)。 8字节与9
字节。

除非您正在谈论数百万行正在处理,否则不太可能显着改变性能。
BIGINT is stored one byte smaller than DECIMAL(18,0). 8 bytes vs. 9
bytes.

Not likely to significantly change performance unless you''re talking
millions of rows being processed.



-

Don Vaillancourt

软件开发总监

WEB IMPACT INC。

电话:416 -815-2000分机245

传真:416-815-2001

电子邮件:执行** @ web- impact.com < mailto:do ** @ webimpact.com>

web: http://www.web-impact.com
Web Impact Inc.< http://www.web-impact.com>

此电子邮件仅供收信人使用,并包含可能保密和/或版权的

信息。


如果您不是预定的收件人,请通过回复通知发件人

电子邮件并立即删除此电子邮件。


任何人使用,披露或复制此电子邮件除了

预定的收件人是严格禁止的。没有任何陈述

此电子邮件或任何附件没有病毒。病毒扫描建议使用
,并且是收件人的责任。


--
Don Vaillancourt
Director of Software Development
WEB IMPACT INC.
phone: 416-815-2000 ext. 245
fax: 416-815-2001
email: do**@web-impact.com <mailto:do**@webimpact.com>
web: http://www.web-impact.com
Web Impact Inc. <http://www.web-impact.com>
This email message is intended only for the addressee(s) and contains
information that may be confidential and/or copyright.

If you are not the intended recipient please notify the sender by reply
email and immediately delete this email.

Use, disclosure or reproduction of this email by anyone other than the
intended recipient(s) is strictly prohibited. No representation is made
that this email or any attachments are free of viruses. Virus scanning
is recommended and is the responsibility of the recipient.


这是不正确的。 DECIMAL(18,0)使用以十六进制格式存储的9个字节

格式,而不是文本格式。检查BOL。

That is not correct. DECIMAL (18,0) uses 9 bytes stored in hexadecimal
format, not text format. Check BOL.


这篇关于用于PK的数据类型是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆