Sunday, December 9, 2012

PostgreSQL - Copy csv file to table with psql

CREATE TABLE tbl_test
(
 a text,
 b text,
 c text
)
Content of test.csv
a1,b1,c1
a2,b2,c2
a3,b3,c3

psql to COPY
psql -h localhost -U postgres testdb
testdb=# COPY tbl_test FROM 'D:\Temp\test.csv' WITH DELIMITER ',' CSV; 

No comments:

Post a Comment