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.
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.
Sign up to join this communityIf 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