Rads
Rads

Reputation: 195

MySql, Is it a good practice to use 'text' datatype to nullable fields?

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?

or

varchar as the datatype and set default value to null?

Upvotes: 1

Views: 1043

Answers (2)

Yasar Khalid
Yasar Khalid

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

VeeZ Phone
VeeZ Phone

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

Related Questions