MySQL Data Types – numeric types

Integer Types (Exact Value)

Data Types in MySql is important part when you create a new column in table to represent your data. We always need to know which data type is most suitable for our data. Here we are going to understand about MySql Data Type.

Remember 1 Bytes = 8 Bit

Required Storage and Range for Integer Types Supported by MySQL

TypeStorage (Bytes)Minimum Value Maximum Value 
TINYINT (signed)1 (8 bit)-128 (-27)127 (27-1)
TINYINT (unsigned)1 (8 bit)0255 (28 -1)
SMALLINT (signed)2 (16 bit)-32768 (-215)32767 (215-1)
SMALLINT (unsigned)2 (16 bit)065535 (216-1)
MEDIUMINT (signed)3 (24 bit)-8388608 (-223)8388607 (223-1)
MEDIUMINT (unsigned)3 (24 bit)016777215 (224-1)
INT (signed)4 (32 bit)-21474836482147483647
INT (unsigned)4 (32 bit)04294967295
BIGINT (signed)8 (64 bit)-263263 – 1
BIGINT (unsigned)8 (64 bit)0264 – 1

Example of this Data type : Incremented Id

Fixed-Point Types (Exact Value)

The DECIMAL and NUMERIC types store exact numeric data values. It is important to preserve exact precision.

MySQL stores DECIMAL values in binary format.

Example of this Data type : salary, amount, latitude, longitude

Floating-Point Types (Approximate Value)

Data Types : Float, Double

Leave a Reply

Your email address will not be published. Required fields are marked *