MySQL Data Type Reference Table

A data type reference table. If you're designing a database then you don't need me to tell you what this is.

My personal opinion is to always try to use the minimal type and length of the value required. For example, a comment of 500 words should only be TEXT (~64Kb) rather than LONGTEXT (~4Gb).

Data Type Column Type Range or Description Storage
Numeric TinyInt Signed values from -128 to 127 1 byte
    Unsigned values from 0 to 255  
Numeric SmallInt Signed values from -32768 to 32767 2 bytes
    Unsigned values from 0 to 65535  
Numeric MediumInt Signed values from -8388608 to 8388607 3 bytes
    Unsigned values from 0 to 16777215  
Numeric Int Signed values from -2147683648 to 2147483647 4 bytes
    Unsigned values from 0 to 4294967295  
Numeric BigInt Signed values from -9223372036854775808 to 9223372036854775807 8 bytes
    Unsigned values from 0 to 18446744073709551615  
Numeric Float Minimum non-zero values: 1.175494351E-38 4 bytes
    Maximum non-zero values: 3.402823466E+38  
Numeric Double Float Minimum non-zero values: 2.2250738585072014E-308 8 bytes
    Maximum non-zero values: 1.7976931348623157E+308  
Numeric Decimal Varies Maximum width + 2 bytes
String Char Range 1-255 characters Always filled max width
String VarChar Range 1-255 characters Length of string + 1 byte
String TinyBlob, TinyText Max length 255 characters Length of string + 1 byte
String Blob, Text Max length 65535 characters (~64KB of text) Length of string + 2 bytes
String MediumBlob, MediumText Max length 16777216 characters (16MB of text) Length of string + 3 bytes
String LongBlob, LongText Max length 4294967295 characters (4GB of text) Length of string + 4 bytes
String Enum ('value','value2',...) String object that can have only one set of allowed values 1 or 2 bytes
String Set ('value','value2',...) String object that can have one or many values of a set of allowed values. 1, 2, 3, 4, or 8 bytes
Date/Time Date 'YY-MM-DD', 'YYYY-MM-DD', 'YYMMDD' 3 bytes
    Range "1000-01-01" to "9999-12-31"  
Date/Time Time 'HH:MM:SS', 'HHMMSS', 'HHMM', 'HH' 3 bytes
    Range "-838:59:59" to "838:59:59"  
Date/Time DateTime 'YYYY-MM-DD HH:MM:SS' 8 bytes
    "0000-01-01 00:00:00" to "9999-12-31 23:59:59"  
Date/Time TimeStamp 19700101000000 to sometime in the year 2037 4 bytes
Date/Time Year 'YYYY', 'YY' Range "1901" to "2155" 1 byte

Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com

Related Articles

Joes Revolver Map

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4

Ethereum:
Donate to Joel Lipman with Ethereum 0xb038962F3809b425D661EF5D22294Cf45E02FebF
© 2024 Joel Lipman .com. All Rights Reserved.