Mysql2 :: Error: value out of range

I am using MySQL 5.6.10. My diagram is as follows:

Create Table: CREATE TABLE `nba_average_stats` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `ppg` decimal(2,1) DEFAULT '0.0',
  `apg` decimal(2,1) DEFAULT '0.0',
  `rpg` decimal(2,1) DEFAULT '0.0',
  `tpm` decimal(2,1) DEFAULT '0.0',
  `blk` decimal(2,1) DEFAULT '0.0',
  `stl` decimal(2,1) DEFAULT '0.0',
  `year` int(11) DEFAULT '0',
  `player_id` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci

Here is my request:

UPDATE `nba_average_stats` SET `ppg` = 18.6, `apg` = 2.6, `rpg` = 8.4, `tpm` = 0.1, `blk` = 1.5, `stl` = 0.9 WHERE `nba_average_stats`.`id` = 1

And the error:

Mysql2::Error: Out of range value for column 'ppg' at row 1:

Could not create the column correctly ppg? Is my accuracy and / or scale wrong?

+3
source share
1 answer
DECIMAL(M,D)

M is the maximum number of digits
D is the number of digits to the right of the decimal point

Change the column size to (3.1)

+1
source

All Articles