Skip Links

Network World

  • Social Web 
  • Email 
  • Close

Differences between MySQL character data types

Dr. Internet By Steve Blass , Network World , 01/25/2007
Steve Blass
Newsletter Signup
  • Share/Email
  • Tweet This
  • Comment
  • Print

We have an XML schema defining documents that contain paragraphs of text collected from Web-based survey response forms, and we want to store them in a MySQL database. MySQL provides three data types for text storage elements: CHAR, VARCHAR and TEXT. Which is easiest and fastest to work with?

The differences in processing efficiency between MySQL's three character storage types should not have a big impact on processing times unless your data sets are extremely large.

CHAR items, which are fixed length, are the fastest to store and retrieve but can waste storage space.

VARCHAR, a variable-length string, can be slower to store and retrieve but does not waste storage space.

TEXT is a character BLOB that requires more storage space and I/O than the other two.

Using all CHAR fields for text data technically is the fastest choice, but CHAR data items have a maximum length of 255 characters. The latest versions of MySQL allow VARCHAR items to be up to 65,535 characters long, which is the maximum length of a row.

TEXT is appealing because, unlike with VARCHAR, you can put multiple full-size TEXT items in one row. To enable full-text indexing for the data, you will need to use the MyISAM table type for your database regardless of which variable types you choose for your data fields.

  • Share/Email
  • Tweet This
  • Comment
  • Print
Comments (1)
Login
Forgot your account info?

The importance of CBLOBBy Anonymous on May 5, 2007, 8:24 amCBLOB datatype in mysql Re: Differences between MySQL character data types.

Reply | Read entire comment

View all comments

Add comment
Anonymous comments subject to approval. Register here for member benefits.
Have a NetworkWorld account? Log in here. Register now for a free account.

Videos

rssRss Feed