0

I have to insert some rows in the table from the CSV file but if there is already a primary key I must update it. There is a special command for it which is called, ON DUPLICATE UPDATE and it doesn't work with POSTGRES.

I am stuck on it as to how to update the row if PRIMARY KEY already exists.

I am currently using the following query

INSERT INTO STUDENT(name, id) VALUES ('Ravi',2) ON 
DUPLICATE KEY UPDATE name=VALUES(name);

Here Id is the primary key.

Mayank Sharma
  • 203
  • 1
  • 14

0 Answers0