I was trying to duplicate data from an existing table to an empty table in different schema (all in the same database) and got an error. (PostgreSQL 16):
This is for specific exercise, so I have to copy using DDL & DML commands. I have a better way, but I need this to work.
This is the error:
ERROR: Key (name)=(Baker) already exists.duplicate key value violates unique constraint "job_pkey"
ERROR: duplicate key value violates unique constraint "job_pkey"
SQL state: 23505
Detail: Key (name)=(Baker) already exists.
The query I was tried to write look like this:
INSERT INTO table_copy.job_sample (name, description, salary) SELECT name, description, salary FROM table.job;