运行COPY
会导致ERROR: invalid input syntax for integer: ""
我出现错误消息。我错过了什么?
我的/tmp/people.csv
文件:
"age","first_name","last_name"
"23","Ivan","Poupkine"
"","Eugene","Pirogov"
我的/tmp/csv_test.sql
文件:
CREATE TABLE people (
age integer,
first_name varchar(20),
last_name varchar(20)
);
COPY people
FROM '/tmp/people.csv'
WITH (
FORMAT CSV,
HEADER true,
NULL ''
);
DROP TABLE people;
输出:
$ psql postgres -f /tmp/sql_test.sql
CREATE TABLE
psql:sql_test.sql:13: ERROR: invalid input syntax for integer: ""
CONTEXT: COPY people, line 3, column age: ""
DROP TABLE
琐事:
- PostgreSQL 9.2.4