HiveBrain v1.2.0
Get Started
← Back to all entries
debugsqlMinor

Copy from file: ERROR: invalid input syntax for integer: "\N"

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
invaliderrorfilesyntaxinputforfromintegercopy

Problem

My table column defined intcol integer; no NOT NULL constraint. In the load file most values are integers, but a few are null values labeled with the '\N' default as suggested by the copy manual. Can the copy command convert '\N' to null values in the table? I also tried with null 'NA'. Got similar error message.

ERROR:  invalid input syntax for integer: "\N"
CONTEXT:  COPY table_name, line 111, column position3: "\N"


Any trick?

Solution

Use the NULL parameter. From the documentation:


NULL


Specifies the string that represents a null value. The default is \N (backslash-N) in text format, and an unquoted empty string in CSV format.

Example

copy my_table from '/my/csv_file.csv' (format csv, null '\N');

Code Snippets

copy my_table from '/my/csv_file.csv' (format csv, null '\N');

Context

StackExchange Database Administrators Q#189207, answer score: 7

Revisions (0)

No revisions yet.