Mysql2 ::错误:超出范围值

时间:2014-02-13 00:42:35

标签: mysql

我正在使用MySQL 5.6.10。我的架构如下所示:

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

这是我的疑问:

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

错误:

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

我没有正确创建ppg列吗?我的精度和/或比例是否错误?

1 个答案:

答案 0 :(得分:1)

DECIMAL(M,D)

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

将列大小更改为(3,1)