By Joe Gardiner Thursday, 25th March 2010
When creating a table in phpMyAdmin, there is a long list of data types available when naming your fields.
Here is a brief explanation of the different data types available and what the names mean!
Text Types
| Text Type | Description |
| CHAR() | A string of fixed length, with a maximum length of 255 characters. |
| VARCHAR() | A string that can vary in length, with a maximum length of 255 characters. Adding a number in the brackets will determine the string length to be used in the column. |
Note: CHAR()'s offer faster processing for the database as long as all the fields are the same length.
| TINYTEXT | A string with a maximum length of 255 characters. |
| TEXT | A string with a maximum length of 65535 characters. |
| MEDIUMTEXT | A string with a maximum length of 16777215 characters. |
| LONGTEXT | A string with a maximum length of 4294967295 characters. |
| BINARY | Fixed length binary data, with a maximum size of 8000 bytes. |
| VARBINARY | Variable length binary data, with a fixed length of 8000 bytes. |
Blobs are treated as binary strings and can store large amounts of information, but are processed much slower.
| TINYBLOB | A string with a maximum length of 255 characters. |
| BLOB | A string with a maximum length 65535 characters |
| MEDIUMBLOB | A string with a maximum length of 16777215 characters. |
| LONGBLOB | A string with a maximum length of 4294967295 characters. |
| ENUM | Is short for enumeration, and means that each column may have one of a list of predetermined values e.g. age brackets 18 - 25, 26 - 35, etc. |
| SET | Similar to ENUM, but each column may have more than one value from a predetermined list. |
Numeric Types
INT types have an option called UNSIGNED. Normally integers are between a negative and a positive number, but UNSIGNED will start the range at 0 instead of a negative number
| INT type | Normal | Unsigned |
| TINYINT | -128 to 127 | 0 to 255 |
| SMALLINT | -32768 to 32767 | 0 to 65535 |
| MEDIUMINT | -8388608 to 8388607 | 0 to 16777215 |
| INT | -2147483648 to 2147483647 | 0 to 4294967295 |
| BIGINT | -9223372036854775808 to 9223372036854775807 | 0 to 18446744073709551615 |
| DOUBLE | A large number that has a floating decimal point. |
| DECIMAL | A DOUBLE that is stored as a string, not an INT, and has a fixed decimal point |
| FLOAT | A small nuber that has a floating decimal point |
| REAL | A single precision floating point decimal number. |
| BIT | An integer than can only take the values of 1, 0 or null, and is one bit in size. |
| BOOLEAN | A true or false data value, 1 or 0, on or off! |
| SERIAL | A four byte integer that automatically increases by 1 |
Date and Time
| Data Type | Description |
| DATE | Date that follows the format rules of: YYYY-MM-DD |
| DATETIME | Date and time that follows the format rules of: YYYY-MM-DD HH:MM:SS |
| TIMESTAMP | Date and time that follows the format rules of: YYYYMMDDHHMMSS |
| TIME | Date and time that follows the format rules of: HH:MM:SS |
| YEAR | A year in two or four digit format, 58, or 1958 |
Posted in Guides, MySQL |
No Comments »