PostgreSQL,尝试将日期列从 csv 文件复制到 table 的列

PostgreSQL, trying to copy column of dates from csv file to table's column

我有一个 PostgreSQL table,其中包含一个 'date'

类型的空列

我正在尝试从 CSV 文件复制日期值。

但是它提出了这个:

COPY books (publication_date) FROM 'path/to/file/pub.csv' CSV;
ERROR:  date/time field value out of range: "11/31/2000"

此值位于 CSV 的索引 8178 处,因此并非整个文件有问题。

我不明白为什么,因为日期看起来非常合适。

那么,我该如何解决这个问题或让 Postgres 忽略错误的日期呢?

ERROR:  date/time field value out of range: "11/31/2000"

I don't understand why, as the date seems perfectly fine.

嗯,11月只有30天,所以日期确实无效。

您需要将日期样式设置为所需的格式。
https://www.postgresql.org/docs/7.2/sql-set.html
https://www.postgresql.org/docs/9.1/runtime-config-client.html#GUC-DATESTYLE

SET datestyle = DMY;