MySQL | Data Types | Conditions | Queries | Relationships | Scripts
Data types must define each table column...
CHAR declares a 'string' value the length of the column. VARCHAR declares a 'string' value the length of the 'string'. Character lengths are declared in ( ) parenthesis...
CHAR() 255 characters max
VARCHAR() 255 characters max
BLOB declares binary strings and is case-sensitive. TEXT declares non-binary strings and is not case-sensitive...
TINYBLOB or TINYTEXT 255 characters max
BLOB or TEXT 65535 characters max
MEDIUMBLOB or MEDIUMTEXT 16777215 characters max
LONGBLOB or LONGTEXT 4294967295 characters max
INT declares a numeric value. INT can be defined with UNSIGNED, declaring only zero or positive numbers. INT can also be defined with ZEROFILL, declaring the extra number's places to be filled in with zeroes. ZEROFILL is automatically UNSIGNED. Number lengths are declared in ( ) parenthesis...
TINYINT() -128 to 127 (or 255 as UNSIGNED)
SMALLINT() -32768 to 32767 (or 65535 as UNSIGNED)
INT() -2147483648 to 2147483647 (or 4294967295 as UNSIGNED)
CURRENCY currency value
DECIMAL( , ) fixed decimal point
DOUBLE( , ) large number with a floating decimal point
FLOAT small number with a floating decimal point
DATE in the format of YYYY-MM-DD
DATETIME in the format of YYYY-MM-DD HH:MM:SS
TIMESTAMP in the format of YYYYMMDDHHMMSS
TIME in the format of HH:MM:SS
BOOLEAN a true, false, or null value
Every column generally has a value. Spaces and zeros are values. NOT NULL declares an empty value. NULL declares no value whatsoever...
NOT NULL an empty value
NULL no value
The PRIMARY KEY declares a unique id column. By default, the PRIMARY KEY is defined with NOT NULL, because NULL is not allowed as the PRIMARY KEY...
PRIMARY KEY a unique id column with a numeric data type
FOREIGN KEY a column that refers to the PRIMARY KEY of another table