PostgreSQL Multiple primary keys for table are not allowed
Multiple primary keys for table are not allowed
The cause of error: There is already a primary key created.
Check the primary key or drop the existing primary key.
Create table and primary key
CREATE TABLE test.products( product_id numeric, product_name varchar(500), category varchar(100), price numeric ); ALTER TABLE test.products ADD PRIMARY KEY (product_id);
Messages
CREATE TABLE
ALTER TABLE
Error message example
ALTER TABLE test.products ADD PRIMARY KEY (product_id, product_name);
Messages
ERROR: multiple primary keys for table “products” are not allowed