I have the following setup:
> show create table nums;
+-------+--------------------------------------------------------------------+
| Table | Create Table |
|-------+--------------------------------------------------------------------|
| nums | CREATE TABLE `nums` ( |
| | `num` decimal(15,8) DEFAULT NULL |
| | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |
+-------+--------------------------------------------------------------------+
$ cat num_file
8.04
$ echo "load data local infile 'num_file' into table nums (@num)
set num=truncate(@num,8);" | mysql
I would expect that the table would contain 8.04, but instead:
> select * from nums;
+------------+
| num |
|------------|
| 8.03999999 |
+------------+
Why is this happening, and how can I fix it?