MySQL 27 - TEXT, TINYTEXT, MEDIUMTEXT, LONGTEXT

846 views

0   0

The TEXT data types have not yet been discussed, but they are another string data type. They are similar to the VARCHAR data type with some minor differences that are important to know.

The first thing to note is that there are four versions used to determine different sizes. From least to greatest size is TINYTEXT, TEXT, MEDIUMTEXT, LARGETEXT. These each have different maximum byte sizes: 255, 65535, 16 million something, and 4 billion something.

You create a column as one of these data types just as you would with a varchar column. You work with them exactly the same, too. If that is the case, what are the primary differences between these and VARCHAR?
The first difference is that VARCHAR is restricted by the row limit of a table. TEXT tables do not contribute nearly as much (max of 12 bytes) because the data is not stored inline in the table. This means that if you need to allow for extra space for other rows, you can use a TEXT column. And even though the table only contains a pointer to the data, it is all hidden to us and working with a TEXT column is the same as working with a VARCHAR column.
The second primary difference is that TEXT data types do not allow for a default other than NULL.

Thirdly, VARCHAR is limited to just under 64KB, whereas you can use MEDIUMTEXT or LARGETEXT to allow for more storage. So if what you are trying to store as an individual value is over 64KB, use a text column.

Other than those three things, VARCHAR will usually work just fine for our text needs.

Now, last thing is that these data types are often called CLOB data types.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Support me! http://www.patreon.com/calebcurry

Subscribe to my newsletter: http://eepurl.com/-8qtH

Donate!: http://bit.ly/DonateCTVM2.

~~~~~~~~~~~~~~~Additional Links~~~~~~~~~~~~~~~

More content: http://CalebCurry.com
Facebook: http://www.facebook.com/CalebTheVideoMaker
Google+: https://plus.google.com/+CalebTheVideoMaker2
Twitter: http://twitter.com/calebCurry

Amazing Web Hosting - https://www.dreamhost.com/r.cgi?1487063 (The best web hosting for a cheap price!)
View More
Comments

0 Comments