postgresql 我应该如何使用 pgAdmin 3 将数据从 CSV 导入 Postgres 表?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19400173/
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
How should I import data from CSV into a Postgres table using pgAdmin 3?
提问by abhim
Is there any plugin or library which I need to use for this? I want to try this on my local system first and then do the same on Heroku Postgresql
我需要为此使用任何插件或库吗?我想先在我的本地系统上尝试这个,然后在 Heroku Postgresql 上做同样的事情
回答by Tomas Greif
pgAdmin has GUI for data import since 1.16. You have to create your table first and then you can import data easily - just right-click on the table name and click on Import.
pgAdmin 自 1.16 起具有用于数据导入的 GUI。您必须先创建表,然后才能轻松导入数据 - 只需右键单击表名称,然后单击“导入”。
回答by abhim
assuming you have a SQL table called mydata - you can load data from a csv file as follows:
假设您有一个名为 mydata 的 SQL 表 - 您可以从 csv 文件加载数据,如下所示:
COPY MYDATA FROM '<PATH>/MYDATA.CSV' CSV HEADER;
For more details refer to: http://www.postgresql.org/docs/9.2/static/sql-copy.html
更多详情请参考:http: //www.postgresql.org/docs/9.2/static/sql-copy.html
回答by Rajitha Bandara
You may have a table called 'test'
您可能有一张名为“test”的表
COPY test(gid, "name", the_geom)
FROM '/home/data/sample.csv'
WITH DELIMITER ','
CSV HEADER