What are the numeric data types in MySQL?

Beginner

Answer

MySQL numeric types include:

Integer Types:

  • TINYINT: 1 byte (-128 to 127)
  • SMALLINT: 2 bytes (-32,768 to 32,767)
  • MEDIUMINT: 3 bytes (-8,388,608 to 8,388,607)
  • INT: 4 bytes (-2,147,483,648 to 2,147,483,647)
  • BIGINT: 8 bytes (very large range)

Decimal Types:

  • DECIMAL/NUMERIC: Exact precision, for financial data
  • FLOAT: 4 bytes, approximate precision
  • DOUBLE: 8 bytes, double precision
CREATE TABLE products (
    id INT AUTO_INCREMENT PRIMARY KEY,
    price DECIMAL(10,2),
    weight FLOAT,
    quantity SMALLINT UNSIGNED
);