postgresql 使用 pgAdmin 导入文本文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11973609/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
importing a text file using pgAdmin
提问by Beardo
I have just downloaded pgAdmin 1.14.3 in an effort to import, query, and manage large textfiles. These textfiles are either quote comma quote delimited or tab delimited (they come as quote comma quote and I edited many for use with another software). While version 1.16 allows an import function, it has not been released yet and I am wondering how to import data into a newly created table using pgAdmin.
为了导入、查询和管理大型文本文件,我刚刚下载了 pgAdmin 1.14.3。这些文本文件要么是引号逗号分隔的,要么是制表符分隔的(它们以引号逗号的形式出现,我编辑了许多以便与其他软件一起使用)。虽然 1.16 版允许导入功能,但它尚未发布,我想知道如何使用 pgAdmin 将数据导入到新创建的表中。
The text files range from 12MB to 2GB, so I'm looking for a comprehensive solution that would not involve importing row by row. I tried this with phppgadmin, but ran into file size limitations embedded in the php.ini file (separate post) and am trying this as a possible workaround. I'm a little new to SQL, so not really sure of all the commands possible at my fingertips. Any helps is appreciated - thanks!
文本文件的范围从 12MB 到 2GB,因此我正在寻找一种不涉及逐行导入的综合解决方案。我用 phppgadmin 尝试了这个,但遇到了嵌入在 php.ini 文件中的文件大小限制(单独的帖子),我正在尝试将此作为可能的解决方法。我对 SQL 有点陌生,所以不太确定所有可能触手可及的命令。任何帮助表示赞赏 - 谢谢!
回答by dezso
You can issue a COPY
statement, like this:
您可以发布COPY
声明,如下所示:
COPY table_name (column_name)
FROM 'd:\test.sql';
Query returned successfully: 6 rows affected, 31 ms execution time.
See the documentation here: http://www.postgresql.org/docs/9.1/static/sql-copy.html
请参阅此处的文档:http: //www.postgresql.org/docs/9.1/static/sql-copy.html
Note that I did not test this in PgAdmin for large files, but using psql I have never seen a case where the file had been too big for COPY
.
请注意,我没有在 PgAdmin 中测试大文件,但是使用 psql 我从未见过文件对于COPY
.