Many people say to me that set VARCHAR(100) doesnt make sense. It the same as put 255. I’d like to know why…
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That’s rubbish. They may be talking about the fact that a
varcharuses one byte for the length regardless of whether the maximum length is 100 or 255 ( lengths above that will use two bytes, up to ~64K) but they are treated differently.If you insert a 150-character string into the former, it will be truncated to 100, that’s not so for the latter case.
You should use the length that makes sense. If you have a column that will never exceed 30 characters, don’t use
varchar(255).See here for the type details.