2017-07-11 5 views
0

私が実行しようとして問題が生じています\私の列名が、私は次のことを試してみたDESCPostgresの9 COPY - 予約キーワード

でコピーコマンド:

psql -U user -p 1234 -h hostname -c "\copy schema.table (desc) from /my/file.txt WITH DELIMITER '|' HEADER CSV " db 
psql -U user -p 1234 -h hostname -c "\copy schema.table ('desc') from /my/file.txt WITH DELIMITER '|' HEADER CSV " db 
psql -U user -p 1234 -h hostname -c "\copy schema.table ("desc") from /my/file.txt WITH DELIMITER '|' HEADER CSV db 

I毎回同じエラーが発生します:

ERROR: syntax error at or near "desc" 

私はそれを回避することはできません。私が紛失しているものがありますか?

答えて

0

はちょうどここのように、二重引用符をエスケープ:偉大な仕事を

[email protected]:~$ psql -c "copy s1(\"desc\") from stdin;" 
Enter data to be copied followed by a newline. 
End with a backslash and a period on a line by itself. 
>> b 
>> \. 
COPY 1 
[email protected]:~$ psql 
psql (9.6.3) 
Type "help" for help. 

vao=# select * from s1; 
i | desc 
---+------ 
    | a 
    | b 

(2 rows) 
+0

おかげで、! – kiket2ride

関連する問題