How to specify a tab in a postgres front-end COPY
I would like to use the psql "\copy" command to pull data from a tab-delimited file into Postgres. I'm using this command:
\copy cm_state from 'state.data' with delimiter '\t' null as ;
But I'm getting this warning (the table actually loads fine):
WARNING: nonstandard use of escape in a string literal
LINE 1: COPY cm_state FROM STDIN DELIMITER '\t' NULL AS ';'
HINT: Use the escape string syntax for escapes, e.g., E'\r\n'.
How do I specify a tab if '\t' is not correct?
Use E'\t'
to tell postgresql there may be escaped characters in there:
\copy cm_state from 'state.data' with delimiter E'\t' null as ';'
you can do this copy cm_state from stdin with (format 'text')