Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drop primary key index

Can I drop primary key index without dropping primary key constraint in postgresql?

like image 390
Ruwani Avatar asked Feb 24 '26 12:02

Ruwani


1 Answers

Your question is a bit confusing. I think you must mean this:

Can I drop an index on a column but still keep the uniqueness constraint on that column?

No. A uniqueness constraint requires an index. You can make your constraint into an ordinary non-primary index, but you can't make it not an index.

Also, read about primary keys in the documentation:

Technically, a primary key constraint is simply a combination of a unique constraint and a not-null constraint.

So if a column is a primary key it has by definition a unique constraint and therefore also an index. You cannot have a primary key that isn't an index.

like image 70
Mark Byers Avatar answered Feb 27 '26 03:02

Mark Byers



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!