问题描述
如果我决定将主键设为一串数字
vs实际数字会不会有意义?在
效率方面,它会对DB2产生什么影响吗?为什么你会为一个字符串选择数字?
不需要是数字格式?
谢谢
-
回复newsgroupsurferATyahooDOTcom
would it matter if I decided to make a primary key a string of numbers
vs actual numbers ? would it make any difference to DB2 in terms of
efficiency ? why would you choose numeric over a string for a key that
does not need to be in numeric format ?
thanks
--
reply to newsgroupsurferATyahooDOTcom
推荐答案
可能是物理数据库中最重要的区别级别是
INTEGER需要4个字节的存储空间,而你需要
CHAR(10)来存储相同的值范围。
但是,这绝不应该在物理数据库级别决定。
您的数据模型将(应该)始终确定适当的域名
您的属性。
Probably the most significant difference at a physical database level is
the fact that INTEGERs require 4 bytes of storage, while you would need
CHAR(10) to store the same range of values.
However, this should never be decided at a physical database level.
Your data model will (should) always determine the proper domain for
your attributes.
物理数据库级别上最重要的区别可能是 CHAR(10)来存储相同范围的值。
然而,这绝不应该在物理上决定数据库级别。
您的数据模型将(应该)始终确定您的属性的正确域。
Probably the most significant difference at a physical database level is
the fact that INTEGERs require 4 bytes of storage, while you would need
CHAR(10) to store the same range of values.
However, this should never be decided at a physical database level.
Your data model will (should) always determine the proper domain for
your attributes.
确实!我刚刚与一位客户对抗,其中设备ID是一个编码的bb。 比特范围是指比特范围。实现为INTEGER。
接下来我听到的是为什么DB2不支持UNSIGNED INTEGER因为
我们松开了0x8000000位。
在经过一些患者解释并指向
a混合环境中的小端和大端后,他们现在正朝着CHAR(4)for BIT DATA(又名
BINARY)的方向前进。
数据类型没有事后的想法....
干杯
Serge
-
Serge Rielau
DB2 SQL编译器开发
IBM多伦多实验室
Indeed! I''ve just been butting heads with a customer where a "device ID"
which is an "encoding" of "bit ranges" was implemented as INTEGER.
Next thing I hear is "Why doesn''t DB2 support UNSIGNED INTEGER because
we loose the 0x8000000 bit."
After some patient explanation and pointing to little and big endian in
a mixed environment they are inching towards CHAR(4) FOR BIT DATA (aka
BINARY) now.
Data types are no afterthought....
Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
这篇关于字符串与数字类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!