I would like to make a simple notice / news system for website administrators.
What is the best solution, to store those messages (up to 250 characters) in database?
VARCHAR(255) or TEXT?
Thanks
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.
If they are to be short, define a hard upper limit and use VARCHAR(). If you don’t think they’ll go above 250 chars, make the size
VARCHAR(512)to give yourself plenty of room to change your mind at a moment’s notice. (You could always alter the column definition later anyway).TEXTandBLOBtypes are really intended for data of unknown/undetermined/unlimited length. If you have no problem defining a limit, then define one and useVARCHAR(). You’ll get more flexibility out of sorting and indexing fromVARCHAR(), asTEXTcan only use up tomax_sort_lengthbytes to sort on.If it matters for your use case, you cannot assign a default value to
TEXTcolumns.Much of this is detailed in the MySQL documentation on
BLOB&TEXTtypes.