我从Mockaroo下载了数据,其中列价格确实存在货币符号。
create table car (
id BIGSERIAL NOT NULL PRIMARY KEY,
make VARCHAR(100) NOT NULL,
model VARCHAR(100) NOT NULL,
price NUMERIC(19, 2) NOT NULL
);
insert into car (id, make, model, price) values (1, 'Oldsmobile', 'Intrigue', '$754.65');
insert into car (id, make, model, price) values (2, 'Dodge', 'Intrepid', '$913.84');
insert into car (id, make, model, price) values (3, 'Chevrolet', 'S10', '$573.35');
insert into car (id, make, model, price) values (4, 'Ford', 'F-Series', '$528.57');
insert into car (id, make, model, price) values (5, 'Honda', 'Accord', '$495.70');
insert into car (id, make, model, price) values (6, 'Isuzu', 'Trooper', '$489.83');
insert into car (id, make, model, price) values (7, 'Mitsubishi', 'Eclipse', '$637.15');
insert into car (id, make, model, price) values (8, 'Subaru', 'Legacy', '$632.20');
insert into car (id, make, model, price) values (9, 'Mercury', 'Mountaineer', '$566.08');
但是有一个错误:数值类型语法无效。
有什么办法吗?
1条答案
按热度按时间bq8i3lrv1#
数值列(或任何“数字”)不能存储
$
符号,如果确实需要将货币与值一起存储,则需要将其存储在两列中:注意,不应该为生成的列提供值(既不应该为不鼓励的bigserial,也不应该为符合标准的标识列)