One difference between VARCHAR
and TEXT
is that you can declare a DEFAULT
clause for a VARCHAR
column, but not for a TEXT
column.
@Andy is correct that InnoDB stores both VARCHAR
and TEXT
in the same way internally.
FULLTEXT
indexes are supported on both VARCHAR
and TEXT
. Prior to 5.6, you must use MyISAM to get that type of index. In MySQL 5.6, it finally supports FULLTEXT
in InnoDB. Though you should test it carefully, because it seems to return different results than the implementation in MyISAM.
However, Sphinx Search is faster and richer in features than either implementation in MySQL. See my overview in Full-Text Search Throwdown.
@Mohammed asked:
when does VARCHAR
become considered LONG VARCHAR
? Is there a character threshold?
If you declare a length of up to 255 bytes, it can encode the length of a given string using one byte. If you declare the column max length over 255 bytes, it will use two bytes to encode the length.
You can declare a column as LONG VARCHAR
, but this is really just an alias for MEDIUMTEXT.
mysql> create table test ( l long varchar);
mysql> show create table test\G
CREATE TABLE `test` (
`l` mediumtext
) ENGINE=InnoDB DEFAULT CHARSET=latin1