nelsonvarela
nelsonvarela

Reputation: 2370

Duplicate entry check

I'm trying to understand how MSQL's Duplicate Entry works.

What I do understand is when saving

title='aaaaaccccc'

twice and the title field is unique you will get the error: Duplicate entry.

Does MySQL truncates a string with length = 200 to 64 chars and then check if the 64 chars long string is unique?

UPDATE:

When I save 2 records (titles) MySQL complains about violation of a unique constraint when saving the second title. The titles are the same for the first, lets say, 100 chars. After that it differs. Wy does MySQL throws a duplicate key error anyway.

Upvotes: 3

Views: 182

Answers (1)

davek
davek

Reputation: 22915

It depends on the data type: varchar columns will be trimmed, but char columns not (they are padded out to the specified column length).

Upvotes: 1

Related Questions