Field type choice

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

Field type choice

Post by icesolid »

I was wondering what is a better choice for field types in a MySQL database.

I use VARCHAR for most fields. However, some fields may be up to 10000 to 20000 characters and for those fields I use LONGTEXT. Is TEXT sufficient for fields up to 10000 to 15000 characters or should I stick with LONGTEXT?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Have you looked at the storage capacity listing in the MySQL manual?

http://dev.mysql.com/doc/refman/5.0/en/ ... rview.html
icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

Post by icesolid »

From http://dev.mysql.com/doc/refman/5.0/en/ ... rview.html
TEXT[(M)] [CHARACTER SET charset_name] [COLLATE collation_name]

A TEXT column with a maximum length of 65,535 (216 – 1) characters.

An optional length M can be given for this type. If this is done, MySQL creates the column as the smallest TEXT type large enough to hold values M characters long.
So TEXT type has a maximum of 65,535 characters?
Post Reply