Numeric Data Types in MySQL
In this article, we will see about numeric data types in MySQL. Numeric types allows as to stores numbers and it is divided into integer types and real types. Real types allow as to store and process floating point numbers, which means numbers contains floating or decimal point. Whereas integer point allow as to store and process whole numbers, which means numbers without decimal point. Let’s understand numeric types,
Whole numbers
tinyint[(M)]:
- It indicates 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 rannge of unsigned tinyint is 0 to 255.
smallint[(M)]:
- It indicates 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 rannge of unsigned smallint is 0 to 65535.
mediumint:
- It indicates medium integer value.
- The range of M is 1 to 9.
- The range of mediumint is -83, 88,608 to 83, 88,607.
- The rannge of unsigned mediumint is 0 to 1, 67,77,215.
int[(M)]:
- It indicates normal integer value.
- The range of M is 1 to 11.
- The range of int is -214,74,83,648 to 214,74,83,647.
- The rannge of unsigned mediumint is 0 to 429,49,67,295.
bigint[(M)]:
- It indicates big integer value.
- The range of M is 1 to 20.
- The range of int is -infinity to infinity .
Real Types: floating point numbers
float[(M, D)]:
- It indicates single precision floating point value.
- M inidcates 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)]:
- It indicates double precision floating point value.
- M inidcates 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 53.
- The range of D is 1 to 15.
- The range of float is -1.7E+308 to 1.7E+308.