6

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
2
  • 4
    FORCE_NOT_NULL needs a (non empty) comma list of column names after it. It should also be written without the underscores : FORCE NOT NULL col1, col2, ... Commented Mar 18, 2014 at 14:33
  • 1
    Thanks.... can't belive it was the underscores... Commented Mar 19, 2014 at 14:05

1 Answer 1

9

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.