Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgres COPY FORCE_NOT_NULL option not recognized

I'm trying to import a CSV file into Postgres 9.2 using the COPY command. For all columns, empty strings in the CSV must be interpreted as NULL with the exception of one column.

I believe FORCE_NOT_NULL option is meant to allow this, but when I enter the following command:

COPY migr_escolas  from 'C:\escolas.csv' 
     WITH DELIMITER ',' CSV HEADER FORCE_NOT_NULL;

I get the following message:

ERROR:  syntax error next to "FORCE_NOT_NULL" 
LINE 16: ...om 'C:\escolas.csv' WITH DELIMITER ',' CSV HEADER FORCE_NOT_...

Is FORCE_NOT_NULL really supported? If so what's the syntax?

System Info:

"PostgreSQL 9.2.1, compiled by Visual C++ build 1600, 64-bit"
Windows 7 64 bits
like image 520
Grasshopper Avatar asked Mar 18 '14 14:03

Grasshopper


1 Answers

As pointed by joop's comment above, one should use FORCE NOT NULL and not FORCE_NOT_NULL.

like image 92
Grasshopper Avatar answered Oct 09 '22 06:10

Grasshopper