问题描述
使用MySQL管理员GUI工具我已经导出一些从sql转储文件检索到csv文件的数据表。
Using MySQL Administrator GUI tool I have exported some data tables retrieved from an sql dumpfile to csv files.
然后我试图将这些CSV文件导入到PostgreSQL数据库使用postgres COPY命令。我已尝试输入
I then tried to import these CSV files into a PostgreSQL database using the postgres COPY command. I've tried entering
COPY articles FROM '[insert .csv dir here]' DELIMITERS ',' CSV;
以及不带分隔符部分的命令。
and also the same command without the delimiters part.
我得到一个错误:
ERROR: invalid input syntax for integer: "id"
CONTEXT: COPY articles, line 1, column id: "id"
总之,我的问题是和解决这个问题?它可能是与我创建的csv文件的方式有关吗?
In conclusion my question is what are some thoughts and solutions to this problem? Could it possibly be something to do with the way I created the csv files? or have I made a rookie mistake elsewhere?
推荐答案
如果您有标题列,只需将标题限定符添加到复制语句为止
跳过该行的文档
If you have header columns just add the header qualifier to the copy statement as perdocumentation to skip that linehttp://www.postgresql.org/docs/8.4/static/sql-copy.html
这篇关于将CSV文件导入PostgreSQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!