我正在将 CSV 文件中的数据导入到 postgreSQL 表中。
该表如下所示:
CREATE TABLE foo_stats (
td DATE NOT NULL,
ins_id INTEGER CHECK (ins_id > 0) NOT NULL,
df_id INTEGER CHECK (df_id > 0) NOT NULL,
pc REAL NOT NULL DEFAULT 0.0,
ph REAL DEFAULT 0.0 NOT NULL,
pl REAL DEFAULT 0.0 NOT NULL,
av REAL DEFAULT 0.0 NOT NULL,
cv BIGINT DEFAULT 0 NOT NULL,
avi REAL DEFAULT 0.0 NOT NULL,
cmi BIGINT DEFAULT 0 NOT NULL,
vwp REAL CHECK (vwp >= 0) NOT NULL,
atr REAL NOT NULL DEFAULT -99999,
pv REAL NOT NULL DEFAULT -99999,
pr REAL NOT NULL DEFAULT -99999,
PRIMARY KEY (ins_id, df_id, td)
);
在批量复制之前,我使用删除主键ALTER TABLE DROP CONSTRAINT PRIMARY KEY
这是我COPY
在 psql CLI 调用命令时的 CL 跟踪:
mydb=# COPY foo_stats FROM '/path/to/data/foo_stats.csv' WITH CSV;
ERROR: invalid input syntax for integer: "1990-01-02"
CONTEXT: COPY foo_stats, line 1, column id: "1990-01-02"
mydb=#
以下是输入 CSV 文件的前几行:
"1990-01-02",388,3,-99999,0.913,0.91,0.0,0,0.0,0,0,-99999,-99999,-99999
"1990-01-02",388,4,-99999,0.913,0.91,0.0,0,0.0,0,0,-99999,-99999,-99999
"1990-01-02",388,1,-99999,0.913,0.91,0.0,0,0.0,0,0,-99999,-99999,-99999
"1990-01-02",388,7,-99999,0.913,0.91,0.0,0,0.0,0,0,-99999,-99999,-99999
"1990-01-02",388,6,-99999,0.913,0.91,0.0,0,0.0,0,0,-99999,-99999,-99999
输入文件中的数据列与表模式中的顺序相同。谁能解释为什么我收到错误消息?
PS:我在 Ubuntu 10.0.4 LTS 上使用 PostgreSQL 8.4