4

I am creating a project that will hold long text.Probably paragraphs...Now what data type should I use for my datatable fields? I am using mySQL workbench...thanks

PeterJohn
  • 589
  • 3
  • 8
  • 15

5 Answers5

5

I believe TEXT should be appropriate here, unless you are storing binary data. For binary data use BLOB.

Ivaylo Strandjev
  • 69,226
  • 18
  • 123
  • 176
  • I tried to use the longtext then I manually added my question above...error like "data too long" has been encountered. Why? – PeterJohn Feb 05 '13 at 08:13
1

From the documentation: all possible string types.

For long texts, TEXT is most suitable.

Alen Oblak
  • 3,285
  • 13
  • 27
  • 1
    I tried to use the longtext then I manually added my question above...error like "data too long" has been encountered. Why? – PeterJohn Feb 05 '13 at 08:14
0

Depends how long "long" is. For quite long (greater than 64K), text is the weapon of choice, but won't perform as well as varchar, so choose varchar if you know its limit is less than 64K

This article describes the pros and cons of text vs varchar

Bohemian
  • 412,405
  • 93
  • 575
  • 722
0

MySQL VARCHAR size limit is 65535 bytes, and depending on encoding of the column, one char requires 1-4 bytes. If that is not long enough, you can use TEXT type.

"The maximum size of a BLOB or TEXT object is determined by its type, but the largest value you actually can transmit between the client and server is determined by the amount of available memory and the size of the communications buffers."

http://dev.mysql.com/doc/refman/5.5/en/blob.html

Jari Karppanen
  • 406
  • 3
  • 6
0

VARCHAR(0 to 65635 bytes), TEXT( 0 to 65535 bytes), BLOB (0 to 65535 bytes), MEDIUNTEXT(maximum length of 16,777,215 characters), MEDIUMBLOB(maximum length of 16,777,215 characters), LONGTEXT(maximum length of 4,294,967,295 characters), LONGBLOB (maximum length of 4,294,967,295 characters)

DocJ457
  • 797
  • 7
  • 17