我创建了下表:
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)
todecimal(30,10)
改变也不会改变任何东西。
我认为这将是列顺序的问题,但我在其他帖子上读到插入值的顺序无关紧要。