---
title: "Store Float in MySQL"
date: 2023-01-16T17:31:48.000Z
author: Z.SHINCHVEN
tags: [MySQL, Decimal, Float]
canonical: https://atlassc.net/2023/01/16/store-float-in-mysql
---
Storing a float number in MySQL, you must specify the column's precision and scale.

```mysql
CREATE TABLE `test` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `value` decimal(10,2) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
```

- 10: is the `precision`, which is the total number of digits.
- 2: is the `scale`, which is the number of digits after the decimal point.

## Reference

- [Fixed-Point Types (Exact Value) - DECIMAL, NUMERIC](https://dev.mysql.com/doc/refman/8.0/en/fixed-point-types.html)
