Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How many primary keys for one table?can we add more primary keys

Former Member
0 Kudos

In general Table have one primary key.is it possible to more than one primary key in a table?(ie is it possible to add more than one pirmary key in a table). Help me out.

10 REPLIES 10

Former Member
0 Kudos

This message was moderated.

former_member69765
Contributor
0 Kudos

What Kind of table ? a Data base table or a Internal table ?

Well in both types of table, you can have more than one primary key ..

Boobalan .. you are wrong here ..

former_member188594
Active Participant
0 Kudos

Hi,

a unique key or primary key is a candidate key to uniquely identify each row in a table. A unique key or primary key comprises a single column or set of columns. No two distinct rows in a table can have the same value (or combination of values) in those columns. Depending on its design, a table may have arbitrarily many unique keys but at most one primary key.

A primary key is a special case of unique keys. The major difference is that for unique keys the implicit NOT NULL constraint is not automatically enforced, while for primary keys it is. Thus, the values in a unique key columns may or may not be NULL. Another difference is that primary keys must be defined using another syntax.

Hope it is clear.

Reward points if useful.

Best Regards,

Sekhar

Former Member
0 Kudos

Hi,

A table has only one primary key. This is correct but how many columns form this primary key depends on the table.

So from your question I am not sure what is your concern.

If you concern is to have more than one primary key this is not possible.

If your concern is to have more than one filed to be a part of the primary key, then surely this is possible.

I hope this clarifies your answer.

Regards,

Saurabh

Former Member

Hello Kishore,

You can include N no. of fileds as primary key in your table. It will act as a complex primary key.

suppose you have 10 fields in your table. you can declare all the 10 filelds as a primary key. you can not have the two records with the same combination of the primary keys.

Hope this will clarify your query.

reward if helpfull.

Regards,

Naresh.

Former Member
0 Kudos

Hi,

you can have more than one key field as primary key.

EXAMPLE

VBAP,VBEP

jj
Active Contributor
0 Kudos

15 primary keys are possible for a table

jj
Active Contributor
0 Kudos

pls do check this link

[http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ea0b446011d189700000e8322d00/frameset.htm|http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ea0b446011d189700000e8322d00/frameset.htm]

All the key fields of a table must be stored together at the beginning of the table. A non-key field may not occur between two key fields.

A maximum of 16 key fields per table is permitted. The maximum length of the table key is 255.

If the key length is greater than 120, there are restrictions when transporting table entries. The key can only be specified up to a maximum of 120 places in a transport. If the key is larger than 120, table entries must be transported generically.

Former Member
0 Kudos

Yes ,it is possible to have more then 1 primary key.In that case it is said to be composite primary key.

thanks

Lokesh Tripathi

0 Kudos

Hi,

John's answer is absolutly correct. There is a limit for fields in primary key by the database system. The limit is 16 fields, or 15 if you have to use also the CLIENT (client-specific tables).

Regards,

André Klos