MySQL has exact integer types, the exact fixed-point type DECIMAL, and the approximate floating-point types FLOAT and DOUBLE.
Integer types, with their signed ranges:
TINYINT: 1 byte, from -128 to 127SMALLINT: 2 bytes, from -32,768 to 32,767MEDIUMINT: 3 bytes, from -8,388,608 to 8,388,607INT: 4 bytes, from -2,147,483,648 to 2,147,483,647BIGINT: 8 bytes, from-2^63to2^63 - 1
UNSIGNED allows only nonnegative values, so an INT UNSIGNED column holds 0 to 4,294,967,295.
Decimal and floating-point types:
DECIMAL, also calledNUMERIC, stores exact values, for financial data.FLOATuses 4 bytes for single precision, andDOUBLEuses 8 bytes for double precision, soDOUBLEis more precise. Both are approximate, so exact comparisons can fail.
CREATE TABLE products (
id INT AUTO_INCREMENT PRIMARY KEY,
price DECIMAL(10,2),
weight FLOAT,
quantity SMALLINT UNSIGNED
);
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
The diagram below the answer is the concept . Jump to it ↓