Applying PRIMARY KEY constraint in CockroaachDB - multiple primary keys error

Viewed 340

I have created a table in CRDB without having any PRIMARY KEY and populated my data into the table.

Now that the table is created and populated with data I want to apply a constraint to make the first column as PRIMARY KEY. But I get an error:

The constraint is:

ALTER TABLE “MyDB”.“SALES” ADD CONSTRAINT “SALES_PK” PRIMARY KEY (“S_ID”);

and the error is:

pq: multiple primary keys for table “SALES” are not allowed.

I think there reason is in CRDB if no PRIMARY KEY is mentioned, CRDB automatically will assign a PRIMARY KEY to the table named: rowid.

How can I see PRIMARY KEY in a table in CRDB? and How can I Make the column I want as PRIMARY KEY?

1 Answers
Related