问题描述
两种数据类型有什么区别?
var
希望它有所帮助,
Jan M. Nelken
我发现的主要行为差异是尾随
空白的影响。使用varchar,除非您将它们放在数据
项目中,否则没有。使用char,数据总是填充到
数据项的长度。这可能会在许多不同的背景下咬你,并且需要自由应用rtrim。 IMHO char(n)应该只在您确定现在和将来数据总是n个字符的时候才会确定。在
中,每个其他情况都应使用varchat(n)。
what''s the difference of the two data types?
var
Hope it helps,
Jan M. Nelken
The major behavioral difference I have found is the effect of trailing
blanks. With varchar, there are none unless you place them in the data
item. With char, the data is always padded out to the length of of the
data item. This can bite you in many different contexts and requires
liberal application of rtrim. IMHO char(n) should only when you certain
that now and in the future the data will always be n characters long. In
every other case varchat(n) should be used.
这篇关于varchar vs char的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!