shemj
shemj

Reputation: 31

Combined primary key in database relation

I have been looking for information across the web and books and cant seem to find any information on this. From my understanding of primary keys it is not possible. But can all columns in a table be used as a combined primary key. By this I mean I have a table with 6 columns can all six columns be used as a combined primary key.

Upvotes: 1

Views: 132

Answers (2)

nvogel
nvogel

Reputation: 25526

It is quite possible for a table to consist of just a key and to have no non-key attributes. Semantically such a table identifies the existence of entities without recording any additional information about them. Examples might be a table of IP addresses authorised to access a system or a table or co-ordinates identifying points in an N-dimensional space. In order to update, delete or retrieve an individual tuple in such a table the full set of values for the tuple has to be specified.

Upvotes: 2

Denorm
Denorm

Reputation: 466

In Oracle you could do this:

alter table table_name add constraint table_name_pk primary key(column1, column2, column3, column4, column5, column6);

In Oracle, composite primary key constraints are limited to 32 columns.

Refer to this:

http://docs.oracle.com/cd/B10500_01/server.920/a96524/c22integ.htm

Upvotes: 0

Related Questions