Below, I’ve listed all the MySQL column types you should ever need to utilize when creating database tables.
And I’ve also listed common column options and settings for easy reference.
The MySQL column types
INT
— a numeric integer valueVARCHAR
— standing for “varied-length character”, used for shorter pieces of texts, like a nameTEXT
— used for longer pieces of text, like a descriptionBOOLEAN
— used for boolean, true/false, valuesTIMESTAMP
— used to store a combination date & timeDATE
— a date; format:YYYY-MM-DD
(e.g. February 1, 2000 would be2000-02-01
)TIME
— a time; format:HH:MM:SS
(e.g. 3 hours, 2 minutes, and 12 seconds would be03:02:12
DATETIME
— a point in time, a date and time; format:YYYY-MM-DD HH:MM:SS
(e.g. November 26, 2015 at 3:30pm and 23 seconds would be2015-11-26 15:30:23
)YEAR
— a year, e.g. 1776DECIMAL
— used to store a decimal numeric valueENUM
— used to store a multiple choice value, where only one value can be selectedSET
— used to store a multiple choice value, where multiple values can be selected
Common MySQL column options & settings
Null
— designates that a column is optionalPRIMARY
, or primary key — says says to the database table: “this column contains each object’s unique identifier!”A_I
, or auto-increment — automatically assign each newly-created object the next available integer valueLength
— used to specify the number of characters allowed forCHAR
andVARCHAR
columnsValues
— used to specify the values available forENUM
andSET
columns