Month: May 2009

Maxlength for MySQL TEXT field types


MySQL supports four TEXT field types (TINYTEXT, TEXT, MEDIUMTEXT and LONGTEXT)

MyISAM tables in MySQL have a maximum row size 65,535 bytes and all the data in a row must fit within that limit.

Luckily however TEXT field types are stored outside of the table itself and thus only contribute 9 – 12 bytes towards that limit.

Further reading is here.

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.

The maximum amount of data that can be stored for each data type is approximately:

TINYTEXT 256 bytes
TEXT 65,535 bytes ~64kb
MEDIUMTEXT 16,777,215 bytes ~16MB
LONGTEXT 4,294,967,295 bytes ~4GB

So most of the time TEXT will suffice, but if you are scratch building a CMS it might be an idea to think about MEDIUMTEXT

Update: (20/05/2014) – I see a lot of hits on this page, so I thought I’d spell out the information here for the terms you seem to be searching for…

TINYTEXT is a string data type that can store up to to 255 characters.

TEXT is a string data type that can store up to 65,535 characters. TEXT is commonly used for storing blocks of text such as the body of an article.

MEDIUMTEXT is a string data type with a maximum length of 16,777,215 characters. Use MEDIUMTEXT if you need to store large blocks of text, such as a book.

Understanding CSS Class and ID


Often these selectors can confuse beginners. In CSS a class is represented by a dot “.” while an id is a hash “#”. Simply put an id is used on a unique style that doesnt repeat whilst a class can be re-used.

Often it can be hard to decide where to use a class versus an id for an element

Use a class tag if:

1.The style is used in various places throughout the document.
2.The style is very general.

Use an id tag if:

1.The style is only used once ever in the document.
2.The style is specific to a certain area of the document.

Remember that an id can only appear once in any HTML document. Once you’ve used that id it should not be used again on that page.