Is PRIMARY KEY unique by default?

The PRIMARY KEY declaration in the examples is:

(ID INTEGER NOT NULL, …/… PRIMARY KEY(ID))

Is it UNIQUE by default ?

Others will correct me, but I think it depends on the sql engine. In postgres, for example, the answer is yes. It’s also not null by default.

As a PRIMARY KEY is an unique record identifier by definition, I guess that in all DBs it is unique as it should be. If it wouldn’t, it would be an inconsistency against the concept.

2 Likes

In my opinion, any engine that doesn’t treat it unique by default should be promptly uninstalled.

3 Likes