Reputation: 111
I am making a table of users where I will store all their info: username, password, etc. My question is: Is it better to store usernames in VARCHAR with a utf-8 encoded table or in CHAR. I am asking because char is only 1 byte and utf-8 encodes up to 3 bytes for some characters and I do not know whether I might lose data. Is it even possible to use CHAR in that case or do I have to use VARCHAR?
Upvotes: 1
Views: 325
Reputation: 1269763
In general, the rule is to use CHAR
encoding under the following circumstances:
CHAR
.In other cases, use VARCHAR()
. In practice, users of the database don't expect a bunch of spaces at the end of strings.
Upvotes: 2