How to specify a tab in postgres front-end COPY

I would like to use the psql "\ copy" command to retrieve data from a tab delimited file in Postgres. I use this command:

\copy cm_state from 'state.data' with delimiter '\t' null as ; 

But I get this warning (the table really 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, eg, E'\r\n'. 

How to specify a tab if "\ t" is incorrect?

+48
postgresql
May 24 '11 at 3:45
source share
2 answers

Use E'\t' to tell postgresql that there may be escaped characters:

 \copy cm_state from 'state.data' with delimiter E'\t' null as ; 
+108
May 24 '11 at 16:03
source share

you can do this copy cm_state from stdin with (format 'text')

+2
Mar 08 '17 at 20:13
source share



All Articles