I was creating table name "tripsdata" in SQL query tool, which is done successfully. Now I have to insert values into the table and I used the below syntax :
LOAD data INFILE 'tripsdata.csv'
INTO TABLE tripsdata
FIELDS TERMINATED BY ','
ENCLOSED BY '"' LINES TERMINATED BY 'n'
IGNORE 1 ROWS;
It keeps giving me error – "ERROR: syntax error at or near "data"
LINE 2: LOAD data INFILE ‘tripsdata.csv’ "
Can you share the error and rectification?
tried what I mentioned above. I want to create this table using SQL query:
2
Answers
LOAD DATA
is a MySQL command. PostgresSQL uses COPY. I suspect what you’re trying to do is import a CSV file while skipping the header row. You can do that with theFORMAT CSV
andHEADER ON
options:You can as well try this query:
COPY tripsdata FROM 'tripsdata.csv' WITH CSV HEADER;