2014-02-13 54 views
3

我正在使用MySQL 5.6.10。我的架構如下所示:Mysql2 ::錯誤:超出範圍值

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
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)