如果我输入两个只有空格的字符串。我将收到此错误消息:
错误 1062:重复条目 ''' 键'PRIMARY'
如何关闭“自动修剪”?
我正在使用这个Charset: uft8-uft8_bin
和这个数据类型:Varchar
。
根据SQL 92文档,当比较两个字符串时,首先通过用空格填充最短的字符串使它们的长度相等。
8.2 <comparison predicate>
在文档中搜索。
If the length in characters of X is not equal to the length
in characters of Y, then the shorter string is effectively
replaced, for the purposes of comparison, with a copy of
itself that has been extended to the length of the longer
string by concatenation on the right of one or more pad char-
acters, where the pad character is chosen based on CS. If
CS has the NO PAD attribute, then the pad character is an
implementation-dependent character different from any char-
acter in the character set of X and Y that collates less
than any string under CS. Otherwise, the pad character is a
<space>.
换句话说。它不是将值与您输入的空格量一起存储,而是它用于检查重复主键的比较。因此,您不能将具有不同空格数量的两个字符串用作主键