In base alla documentazione SQL 92, quando si confrontano due stringhe vengono prima rese uguali in lunghezza inserendo la stringa più breve con spazi.
Cerca nel documento 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>.
Quindi in altre parole. Non si tratta di memorizzare il valore con la quantità di spazi che hai inserito, ma è il confronto che fa per controllare la chiave primaria duplicata. Quindi non puoi avere due stringhe con una quantità diversa di spazi che fungano da chiave primaria
fonte
2013-02-05 09:04:37
sei sicuro che sia un problema di auto trim? –
Sì, è una chiave primaria e non sono sicuro che sia un problema di assetto automatico .. Ma come posso aggiungere due corde vuote di lunghezza diversa –
La mia prima domanda sarà perché inserire uno spazio vuoto nella colonna? È necessario? Inoltre, se è necessario sei sicuro che la colonna dovrebbe essere una chiave primaria? – Vijay