Reputation: 195
In Mysql, there is a text field which might be null or might have some contents and we're not sure about the length. In this case is it a good practice to use
text as the datatype and set default value to null?
varchar as the datatype and set default value to null?
Upvotes: 1
Views: 1043
Reputation: 71
VARCHARs are a better practice, the TEXT datatype make the queries slower as compared to VARCHARs, use a maximum value for varchar if you do not have Pages of data to store.
Upvotes: 1
Reputation: 427
Varchar is faster than text if size is not too much Because TEXT data types are able to store so much more data than VARCHAR and CHAR field types it makes sense to use them when storing web pages or similar content in the database.
So choose based upon your requirements.
Upvotes: 2