views:

234

answers:

4

I'm setting up a database using PHPMyAdmin and many fields will be large chunks of HTML.

What MySQL datatype & attributes should be used for fields that store large amounts of HTML data?

+3  A: 

TEXT, MEDIUMTEXT, or LONGTEXT

Trevor
in that order depending on data size :)
Ratnesh Maurya
A: 

I think you can store HTML in simple TEXT field. If your html is more then 64KB then you can use MEDIUMTEXT instead.

See also Storage Requirements for String Types for more details about maximum length of stored value.

Also remember than characters in Unicode can require more then 1 byte to store.

Ivan Nevostruev
+1  A: 

You really really should start with the documentation, then if you have questions based on the data types you find there, try to ask for some clarification. But it really helps to understand what the datatypes are before asking the question: Documentation here:

http://dev.mysql.com/doc/refman/5.4/en/data-types.html

That said, take a closer look at text and blob. Text will store a large body of textual information (probably a good choice) where blob is designed for binary data. This does make a difference based on the query functions and what data types they operate on.

Zak
The only reason I say you may want blob is if you are compressing your txt which can also be a space saving thing to do, but severely restricts searchability...
Zak
A: 

I would recommend against storing large chunks of HTML (or other text data) in a database. I find that it's often far more useful to store files as files, and put a filename in the database instead.

On the other hand, if you're doing everything through phpMyAdmin, you may not have that option available to you.

friedo