Application Development and Automation 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: 
Read only

primary key

Former Member
0 Likes
1,387

hi experts,

how many maximum primary keys allowed in one table.

thanks in advance

radhakrishna

11 REPLIES 11
Read only

Former Member
0 Likes
1,214

Hi,

You can have all the fields as primary key in ur table...

No such limit is fixed.

Read only

Former Member
0 Likes
1,214

Hi,

Any number of keys can be used as index keys. But, in the where clause of the select query which uses this table, make sure that u use the first index key.

Else u will get the performance error.

Reward if helpful.

Regards,

Ramya

Read only

nivaskumar2
Explorer
0 Likes
1,214

Hi,

A primary key can consist of multiple columns. However, it is unusual for a key to be constructed from more than five columns, since this makes it difficult for users to enter unique values. The arrangement of the columns behind the keywords PRIMARY KEY defines the key sequence.

Read only

Former Member
0 Likes
1,214

hai Reddy,

there is no such restriction.

Regards.

Eshwar.

Read only

Former Member
1,214

Hello Radhakrishna,

A maximum of 16 key fields per table is permitted.

If you specify more than 16 fields, it gives you the following error message.

Table ZVENKAT123 has more than 16 key fields (violates SAA standard)

Thanks,.

Venkat.O

Edited by: venkat o on Mar 17, 2008 6:00 PM

Read only

dhruv_shah3
Active Contributor
0 Likes
1,214

Hi,

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.

A table may not have more than 249 fields. The sum of all field lengths is limited to 1962 (whereby fields with data type LRAW and LCHR are not counted).

Fields of types LRAW or LCHR must be at the end of the table. Only one such field is allowed per table. There must also be a field of type INT2 directly in front of such a field. The actual length of the field can be entered there by the database interface.

Also check this link

[http://help.sap.com/saphelp_47x200/helpdata/en/cf/21eb6e446011d189700000e8322d00/content.htm]

HTH

Regards,

Dhruv Shah

Read only

Former Member
1,214

16 key fields per table

chan

Read only

Former Member
0 Likes
1,214

Hi

You can have only one primary key in the table. That is why it is called primary

But you can create any number of indexes (also unique which are like a primary key). Too many indexes isn't advised though, as it has impact on the performance of database write.

Rgds

Mat

Read only

Former Member
0 Likes
1,214

Hi,

any number of.

Read only

Former Member
0 Likes
1,214

Hi,

There is no limit on the number of primary keys in a table.

You can use 'n' number of fields as primary key.

Regards,

Sayee

Read only

Former Member
0 Likes
1,214

as said above, there is only ONE primary key.

There can be other secondary keys.

Every key/index can consist of several index fields which are fields of the table.

I do not whether there are restrictions, for the number of indexes and for the number if index fields. If there are, then they could be release dependent and database platform dependent (number of fields seems to be restricted to around 250 fields).

But it does not make much sense to have so many index fields, you need a few selective fields in a index, so moore than 10 fields in unusual.

And it does not make much sense to have too many indexes, the optimzer will be confused. Table changes will become slow. Many tables have only a primary key (which is mandatory), many have only a few secondary keys, very few have around 10 indexes.

Siegfried