MySQL TEXT Field Size Limits

Today while screen scraping pages, and storing the results in a MySQL database table for later parsing, I discovered that MySQL TEXT fields have a limit of 65,536 bytes (2^16 bytes). I did not receive an error when inserting the record so I was not immediately aware of the problem.

It turns out that MySQL will silently truncate your data when you insert anything larger than the allowed 65k bytes in a TEXT field. After some digging on mysql.com I learned that the MEDIUMTEXT field will store 16,777,216 bytes (2^24 bytes) and the LONGTEXT field can handle 4,294,967,296 bytes (2^32 bytes).


About this entry