Numeric Data types in MySQL

Notes:

MySQL Numeric Types: numbers

Integer Types: whole numbers

tinyint[(M)]:
- indicates a tiny integer value
- M indicates length i.e. maximum number of digits a column can hold
- the range of M is 1 to 3
- the range of tinyint is -128 to 127
- the range of unsigned tinyint is 0 to 255

smallint[(M)]:
- indicates a small integer value
- M indicates length i.e. maximum number of digits a column can hold
- the range of M is 1 to 5
- the range of smallint is -32768 to 32767
- the range of unsigned smallint is 0 to 65535

mediumint[(M)]:
- indicates a medium integer value
- M indicates length i.e. maximum number of digits a column can hold
- the range of M is 1 to 9
- the range of mediumint is -83,88,608 to 83,88,607
- the range of unsigned mediumint is 0 to 1,67,77,215

int[(M)]:
- indicates a normal integer value
- M indicates length i.e. maximum number of digits a column can hold
- the range of M is 1 to 11
- the range of int is -214,74,83,648 to 214,74,83,647
- the range of unsigned int is 0 to 429,49,67,295

bigint[(M)]:
- indicates a big integer value
- M indicates length i.e. maximum number of digits a column can hold
- the range of M is 1 to 20
- the range of bigint is -9223372036854775808 to 9223372036854775807
- the range of unsigned bigint is 0 to 18446744073709551615

Real Types: floating point numbers

float[(M,D)]:
- indicates a single precision floating point value
- M indicates length i.e. maximum number of digits a column can hold
- D indicates maximum number of digits allowed after the floating point
- the range of M is 1 to 23
- the range of D is 1 to 7
- the range of float is -3.4E+38 to 3.4E+38

double[(M,D)]:
- indicates a double precision floating point value
- M indicates maximum number of digits a column can hold
- D indicates maximum number of digits allowed after the floating point
- the range of M is 1 to 53
- the range of D is 1 to 15
- the range of double is -1.7E+308 to 1.7E+308

decimal[(M,D)]:
- indicates a double precision fixed point value
- M indicates length i.e. maximum number of digits a column can hold
- D indicates maximum number of digits allowed after the decimal point
- the range of M is 1 to 65
- the range of D is 1 to 30
- the range of decimal is -1.7E+308 to 1.7E+308

boolean: tinyint(1)
- indicates boolean values true or false
- 0 indicates false and 1 indicates true

Interview Questions: