我创建一张桌子
create table if not exists gbpExchangeRates (
date date
, to_currency char(3)
, rate float
, index idx (date, to_currency)
);
然后添加然后尝试插入数据
INSERT INTO gbpExchangeRates ('date', 'to_currency', 'rate') VALUES ('2018-01-22', 'CAD', 1.7253437447) ;
但是我收到以下错误
SQL Error [1064] [42000]: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''date', 'to_currency', 'rate') VALUES ('2018-01-22', 'CAD', 1.7253437447)' at line 1
我尝试了以下操作,但仍收到错误消息:
ALTER TABLE gbpExchangeRates MODIFY to_currency char(10);
ALTER TABLE gbpExchangeRates MODIFY to_currency varchar(10);
ALTER TABLE gbpExchangeRates MODIFY rate double;
ALTER TABLE gbpExchangeRates MODIFY to_currency varchar(10);
INSERT INTO gbpExchangeRates ('date', 'to_currency', 'rate') VALUES ('2018-01-22', 'CAD', 1.72) ;
和变化
我的表和/或插入语句有什么问题?
最佳答案
INSERT INTO gbpExchangeRates (date, to_currency, rate) VALUES ('2018-01-22', 'CAD', 1.7253437447) ;
您不需要引号将字段插入