Duplicate entry for key 'PRIMARY' .Ignoring the spaces for strings

后端 未结 2 629
情书的邮戳
情书的邮戳 2021-01-07 13:11
mysql> CREATE TABLE primary2(boom text,id int,PRIMARY KEY(boom(5)) );
Query OK, 0 rows affected (0.04 sec)

mysql> INSERT INTO primary2 VALUES(\'viok\',1);
Que         


        
2条回答
  •  攒了一身酷
    2021-01-07 13:51

    MySQL ignores trailing spaces in string comparisons. One way is to add a column to store number of trailing spaces the text has.

    One way is to store it as varchar, which allows trailing spaces.

提交回复
热议问题