Search code examples
sqlpostgresqlpgadmin-4

Trying to load data into a table using PostgreSQL?


I am trying to load data into a table using PostgresSQL10.4 and pgAdmin4. My query is below. When I try to use \copy I get the below error.

CREATE TABLE mydata (TimeDate date, Yield float(3))
SELECT * FROM mydata
\copy mydata FROM 'C:\Users\john\Desktop\Stock Prices.csv' WITH CSV;

The above results in the following error:

ERROR:

ERROR:  syntax error at or near "\"
LINE 1: \copy mydata FROM 'C:\Users\john\Desktop\Stock Pri...

Solution

  • You can right click on that particular table & select option to 'Import/Export data" and provide file you want to load into that table.