PostgreSQL:如何将大量数据插入表中?

时间:2014-06-05 10:03:08

标签: postgresql

这里我需要在我的数据库表中插入大量记录。我怎么能在PostgreSQL 9.3版本中做到这一点?

示例

 /* Table creation */

 create table tabletest(slno int,name text,lname text, address text, city text);

 /* Records insertion */

 insert into tabletest values -- Here i need to insert thousands of records in a bulk.

1 个答案:

答案 0 :(得分:2)

简答:使用COPY命令。

Postgres 9.3 documentation

中提供的详细信息

请注意,该文件应该可供Postgres服务器计算机使用,因为COPY主要由DBA使用。

而且,如果你有Excel,你必须首先将数据导出为CSV格式,因为Postgres不能直接读取Excel格式的数据。