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
2,205

In a database table maximum how many primary keys can we have?

19 REPLIES 19
Read only

former_member188829
Active Contributor
0 Likes
2,093
Read only

Former Member
0 Likes
2,093

A table always can have only one primary key. May be number of fields of a table be the part of primary key.

If number of fields are there as primary key then it is called combined primary key, but combination of all fields work as if one.

Read only

Former Member
0 Likes
2,093

Hi Paromita,

I think that it is version dependent.

In the SAP DB version 7.4 the default maximum number of primary key columns is 512 per table.

Regards,

Charles

Read only

Former Member
0 Likes
2,093

each table can have only one primary key

it is a possibility thta one or more fields make that primary key

Read only

Former Member
0 Likes
2,093

Hi paromita

a table can have only 1 primary key.

Thanks and Regards

Shivika

Read only

Former Member
0 Likes
2,093

Hi,

In a table we can have only one primary key combination.that primary key combination can be formed from 16 fields. (these primary key fields should be together and in the first part.after wards only non-primary key fields should be included.otherwise error will get ).

So we cant assign more than 16 fields to primary key combination in datbase table in sap in 4.6 C version.

i tried the same thing.It will not take more than 16 fields.Log wil be generateg you can see there error very clearly.

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

Regds

Sivaparvathi

Please dont forget to reward points if helpful...

Edited by: Siva Parvathi on Jan 4, 2008 2:41 PM

Read only

Former Member
0 Likes
2,093

Check this thread.

Regards,

Maha

Read only

Former Member
0 Likes
2,093

hi

u will have any no. of primary key fields in a table.

regards,

hema.

Read only

Former Member
0 Likes
2,093

Hi Paromitha Roy,

It is not depending on the fields it is depends on length you can check the fields as key fields up to the sum off these field length is equal to 120.

Note: your can create table with 16 key fields and the total length is not greaterthan 120.

Plzz Reward if is useful,

Mahi.

Read only

prasanth_kasturi
Active Contributor
0 Likes
2,093

a table has only one primary key... but it can bea combination of more than one key fields

Read only

Former Member
0 Likes
2,093

Hi,

In relational database design, 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 unique key must uniquely identify all possible rows that exist in a table and not only the currently existing rows. Examples of unique keys are Social Security numbers (associated with a specific person) or ISBNs (associated with a specific book). Telephone books and dictionaries cannot use names or words or Dewey Decimal system numbers as candidate keys because they do not uniquely identify telephone numbers or words.

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.

The relational model, as expressed through relational calculus and relational algebra, does not distinguish between primary keys and other kinds of keys. Primary keys were added to the SQL standard mainly as a convenience to the application programmer.

regards,

vasavi.

reward if helpful.

Read only

Former Member
0 Likes
2,093

Hi paromita Roy Chowdhury,

the no of primary keys is purely version dependent.

the no of primary keys we assume depends on our requirement,the case

where we use more than one primary key is called a candidate key.

a candidate key can be simply explained as a group of columns

which uniquely identifies the table or a row.

In the SAP DB version 7.4 the default maximum number of primary key columns is 512 per table.

plz reward if helpful.

Regards,

Srikanth Tulasi.

Read only

0 Likes
2,093

Hello everyone,

I'm new to BSP and ABAP so there are a couple of things that I'm not sure I understand.

I have a table whose primary key is a combination of 2 fields, one from the table itself and the other comes from another table. I use the RSDMD_WRITE_ATTRIBUTES_TEXTS function (twice : first for the M tabclass and then for the T tabclass) when I need to update a record except that my update do weird things. Example (the first two fields are the primary keys) :

Record # 1 : (IIII, 2009, xxxx)

Record # 2 : (IIII, 2000, yeye)

Record # 3 : (IIII, 2005, nono)

When I modify the text field of record # 1 from xxxx to abcd, the text field of the three records is updated as well to abcd!!

Can someone please help me on that?

Thank you very much!

Regards,

Dimple

Read only

Former Member
0 Likes
2,093

Hi,

You can specify the primary key for your container-managed entity bean when you create the bean, or later when you develop the bean business logic.

The bean’s primary key can be a:

· Simple primary key – consists of one persistent field

· Compound primary key – consists of several persistent fields

· Unknown primary key – the primary key is unknown for the bean provider; at runtime the EJB Container generates automatically the values for that primary key.

Reward if helpful.

Read only

Former Member
0 Likes
2,093

Hi Paramoita,

Any table can have only one primary key.

But the number of fields in a primary key can be more than 1.

If the primary key of a table has only 1 field,then it is a single primary key.

If the primary key of a table contains more than one field in combination,then it is called as a composite primary key.

The maximum number of fields in a primary key is version dependent.For example it is 512 primary key fields for a table in SAP DB version 7.4 .

The number of fields in a composite primary key also depends on the length of the fields.

Reward points if usefull.

Regards,

Kashyap Ivaturi

Read only

Former Member
0 Likes
2,093

Hi Parmita,

In 4.6c version primary keys is 16.

Above 5.0 version primary keys allowed is 532.

thanks

venkat

Read only

Former Member
0 Likes
2,093

Hi,

You can create max of 512 Primary key columns in a Table .

Regards,

Madhavi

Read only

Former Member
0 Likes
2,093

Hi

there is no LIMIT for primary keys

you can have any number of PRIMARY KEYS in a table

it will improve the performance

Read only

Former Member
0 Likes
2,093

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.

please reward if helpful