PDA

View Full Version : MySQL database field size?



marcjacob
03-18-2008, 04:35 AM
Can a MySQL database field contain more than 256 characters? Is there a way to do that or is that the maximum lengh?

Anyone know??

Me ---> :bang:

InsaneSimon
03-18-2008, 05:11 AM
Can a MySQL database field contain more than 256 characters? Is there a way to do that or is that the maximum lengh?

Anyone know??

Me ---> :bang:

TEXT - TINYTEXT - LONGTEXT instead of VARCHAR

marcjacob
03-18-2008, 05:12 AM
So id use longtext instead of varchar? Thanks Simon ill try it!

gaydemon
03-18-2008, 05:14 AM
Yes it can contain as much as you like. But you need to specify what type of column it is.

This is a list of column types:


INT: This stores integer numbers, i.e. 1, 2, 3. Whole numbers without decimal points between -2147483648 and 2147483647.
TINYINT: This stores integers between -128 and 127.
SMALLINT: This stores integers between -32768 and 32767.
MEDIUMINT: This stores integers between -8388608 and 8388607.
BIGINT: This stores integers between -9223372036854775808 and 9223372036854775807.
FLOAT: This stores 32-bit floating point numbers.
DOUBLE: This stores 64-bit floating point numbers.
CHAR: This stores any string up to a maximum size of 255. If you set a CHAR, you must set the maximum size in Column Size.
VARCHAR: This is the same as a CHAR column type except in the way it is stored and retrieved from the database.
TEXT: This stores a (virtually) unlimited amount of text. Use this for storing very large amounts of texts.
DATE: This stores a date defaulting to yyyy-mm-dd format.
ENUM: This stores an enumerated list.If im not totally wrong you set that on a field called "type".

See here for more info (http://www.webdevelopersnotes.com/tutorials/sql/mysql_database_column_types.php3) (ive not read the article myself but seemed to be relevant to your question), or search for "mysql column type".

marcjacob
03-18-2008, 05:22 AM
Thats great, thanks Simon and Bjorn. Ive always just chosen VARCHAR for everthing which is obviously wrong