Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle IDENTITY column versus PRIMARY KEY

Having trouble finding anything definite about whether it's needed to specify that an IDENTITY column as PRIMARY KEY in Oracle 12.2c. Does an IDENTITY column automatically create an index, like a PK? Is it just being redudant? I do believe you can have an IDENTITY column and separate PK, though we are not doing that.

ID NUMBER AS IDENTITY PRIMARY KEY == ID NUMBER AS IDENTITY ?
like image 493
Gandalf Avatar asked Sep 14 '25 09:09

Gandalf


1 Answers

Does an IDENTITY column automatically create an index, like a PK?

No. An identity column is just a column auto-populated with a sequentially generated number. You can use it however you want, but the typical use is as a synthetic primary key.

Is it just being redundant?

No.

I do believe you can have an IDENTITY column and separate PK

Yes, you can.

though we are not doing that.

Fine, if you mean you are not having a separate PK column in addition to the identity column. Defining a PK constraint over the identity column would be a good idea.

like image 163
William Robertson Avatar answered Sep 16 '25 01:09

William Robertson