Whever I try to copy from

test=# \COPY table FROM 'file.csv' WITH ( FORMAT 'CSV', HEADER true );
ERROR:  COPY format "CSV" not recognized

What's the reason for this? I know I've used this before.

1 Answer 1


If format is a string, the string is case sensitive,

test=# \COPY table FROM 'file.csv' WITH ( FORMAT 'csv', HEADER true );

But, the format doesn't have to be a string,

test=# \COPY table FROM 'file.csv' WITH ( FORMAT CSV, HEADER true );

You're probably use to using the non-stringified version. The syntax for the copy_options is pretty hectic,

FORMAT format_name
OIDS [ boolean ]
FREEZE [ boolean ]
DELIMITER 'delimiter_character'
NULL 'null_string'
HEADER [ boolean ]
QUOTE 'quote_character'
ESCAPE 'escape_character'
FORCE_QUOTE { ( column_name [, ...] ) | * }
FORCE_NOT_NULL ( column_name [, ...] )
FORCE_NULL ( column_name [, ...] )
ENCODING 'encoding_name'

A lot of them only accept strings, but some of them accept regular tokens which get lowercased.

This specific thing isn't documented explicitly but you can find more information about COPY here

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.