Problem solve Get help with specific problems with your technologies, process and projects.

Can I put two primary keys in one table?

Can I put two primary keys in one table?

Can I put two primary keys in one table?
By definition, a table can have only one primary key. This is an ANSI SQL restriction, which Oracle supports. However, it is possible for a table to have multiple columns which could serve as a primary key. For instance, a table of employees could have the SSN and EMPID columns. Both columns could be the primary key for this table. In this case, the SSN column and the EMPID columns are called "candidate keys." Both columns are candidates for the primary key constraint. Since only one can be defined as the primary key, you will have to make a choice.

While you can have only one primary key, you can define the other column to be both UNIQUE and NOT NULL, thus essentially...

doing the same thing as the PK constraint.

Dig Deeper on Oracle database design and architecture

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.