0

I am trying to copy user information from csv file into Postgres database and the table name is user.

I can import data from pgAdmin manually. However if I run the COPY user(columns) FROM csvfile... command, it is giving me Syntax error at user.

Is there any solution for this?

When I renamed the user table to usert, it worked and I was able to insert data.

Is the issue because of the table name?

Underoos
  • 4,708
  • 8
  • 42
  • 85

1 Answers1

1

user is a reserved key word. Thus, you'll have to specify the table identifier as a quoted identifier it in double quotes:

COPY "user" (columns) FROM csvfile...

For more, consult the doc on Lexical Structure, specifically the section Identifiers and Key Words.

fphilipe
  • 9,739
  • 1
  • 40
  • 52