【发布时间】:2021-03-31 19:51:34
【问题描述】:
我创建了下表:
CREATE TABLE IF NOT EXISTS `prices_1d` (
`symbol` char(50) NOT NULL,
`open_time` datetime DEFAULT NULL,
`open` decimal(15,8) unsigned DEFAULT NULL,
`high` decimal(15,8) unsigned DEFAULT NULL,
`low` decimal(15,8) unsigned DEFAULT NULL,
`close` decimal(15,8) unsigned DEFAULT NULL,
`volume` decimal(15,8) DEFAULT NULL,
`close_time` datetime DEFAULT NULL,
`quote_av` decimal(15,8) DEFAULT NULL,
`trades` bigint DEFAULT NULL,
`tb_base_av` decimal(15,8) DEFAULT NULL,
`tb_quote_av` decimal(15,8) DEFAULT NULL,
PRIMARY KEY (`symbol`),
KEY `symbol` (`symbol`),
CONSTRAINT `FK__symbols` FOREIGN KEY (`symbol`) REFERENCES `symbols` (`symbol`) ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
这是基于另一个 symbols 列的键控。
当我想使用以下查询向 prices_1d 表中插入一条记录时:
INSERT INTO prices_1d (symbol,
open,
high,
low,
close,
volume,
close_time,
quote_av,
trades,
tb_base_av,
tb_quote_av,
open_time)
VALUES
('AAPL',
19695.87000000,
19888.00000000,
18001.12000000,
18764.96000000,
127698.76265200,
'2020-12-01 23:59:59.999000',
2446070334.82879867,
2023802,
63805.39289800,
1223282816.31921670,
'2020-12-01 00:00:00')
ON DUPLICATE KEY UPDATE open=19695.87000000,
high=19888.00000000,
low=18001.12000000,
close=18764.96000000,
volume=127698.76265200,
close_time='2020-12-01 23:59:59.999000',
quote_av=2446070334.82879867,
trades=2023802,
tb_base_av=63805.39289800,
tb_quote_av=1223282816.31921670,
open_time='2020-12-01 00:00:00'
我收到以下错误:
SQL 错误 (1264):第 1 行的列 'quote_av' 的值超出范围
我不明白,虽然 'quote_av' 失败了,因为即使将列的结构从 decimal(15,8) 更改为 decimal(30,10) 也没有任何改变。
我认为这将是列顺序的问题,但我在其他帖子中读到插入值的顺序无关紧要。
【问题讨论】:
标签: mysql sql-insert on-duplicate-key mysql-error-1264