pc2phone=# COPY * from t_prepaid_history h where to_char(h.fcall_start_time,'YYYYMMDD')='20070218' to '/home/postgres/c.txt' with csv;
ERROR: syntax error at or near "*"
LINE 1: COPY * from t_prepaid_history h where to_char(h.fcall_start_... 我想将2007年2月18日的记录以csv的格式拷贝到/home/postgres/c.txt文件中,但是报错,请问错在哪里?谢谢.
ERROR: syntax error at or near "*"
LINE 1: COPY * from t_prepaid_history h where to_char(h.fcall_start_... 我想将2007年2月18日的记录以csv的格式拷贝到/home/postgres/c.txt文件中,但是报错,请问错在哪里?谢谢.
直接copy from
帮助文档上有例子,东西也很全
COPY tablename [ ( column [, ...] ) ]
FROM { 'filename' | STDIN }
[ [ WITH ]
[ BINARY ]
[ OIDS ]
[ DELIMITER [ AS ] 'delimiter' ]
[ NULL [ AS ] 'null string' ]
[ CSV [ HEADER ]
[ QUOTE [ AS ] 'quote' ]
[ ESCAPE [ AS ] 'escape' ]
[ FORCE NOT NULL column [, ...] ]COPY { tablename [ ( column [, ...] ) ] | ( query ) }
TO { 'filename' | STDOUT }
[ [ WITH ]
[ BINARY ]
[ HEADER ]
[ OIDS ]
[ DELIMITER [ AS ] 'delimiter' ]
[ NULL [ AS ] 'null string' ]
[ CSV [ HEADER ]
[ QUOTE [ AS ] 'quote' ]
[ ESCAPE [ AS ] 'escape' ]
[ FORCE QUOTE column [, ...] ]
还有记得把错误贴到google上,说不定就有答案
主动点
copy from select * from ………………
ERROR: syntax error at or near "from"
LINE 1: COPY from select * from t_prepaid_history where to_char(fcal...
我是在pgadmin上写的,所有后面文件要加斜杠
subquery要加括号,帮助文档上都有的
Note that parentheses are required around the query