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: 

use of primary key

Former Member
0 Kudos

hi experts

Normally databases wont allow more than one primary key..but SAP allows to create more than one primary key... then wats the use of creating primary keys..

correct me if im wrong..

9 REPLIES 9

Former Member
0 Kudos

hi

good

We can have max 16 fields in Primary key for a Table.

This is the standard limit in most of the Databases.

thanks

mrutyun^

Former Member
0 Kudos

You can have only one <u>primary</u> index, but you can have multiple <u>secondary</u> indeces. These are created to speed up SELECTs on these fields.

Rob

Former Member
0 Kudos

Hi,

Primary jeys is nothing but we can save the data without any duplicate records, lets take MM, we have PLANT nad material, if we take only PLANT as primary key, then we can enter the repeted Materila number, that is nothing but the Duplicate, so if we take these 2 are primary keys, then we can not enter the duplicate records into the database

Regards

Sudheer

0 Kudos

k let u solve tis problem... tis s my actual problem

i create an ztable for employee details...

in that i declare empcode and accessno fields as primary keys

while entering data it allows same access code for different employees

but i wan the accesscode field as a uniquekey... thus repitation of

value in that field should not allowed... is there any option in DDIC

for declaring particular field as unique field

ie if we declare more than one key as primary key it allows only one

data for combination of that all primary key fields but allows repeated

datas for a single field, is there any option to avoide that repetation

for a paticular field.

thanks & regrds,

Arun

0 Kudos

Try creating an index on that field and declare it as a unique index.

Rob

0 Kudos

Hi Arun Kumar,

When you define the EMPLOYEE CODE and ACCESS CODE as fields of the primary key, you are telling SAP that you would like to maintain a unique combination of EMPLOYEE CODE and ACCESS CODE. This means that you could have multiple employees with the same ACCESS CODE.

If I understand you correctly you want the ACCESS CODE to be unique for each employee. The solution is simple. Define only the ACCESS CODE as the primary key. Let the EMPLOYEE CODE be an ordinary field. If for any particular reason you would like to access this table using the EMPLOYEE CODE and not the ACCESS CODE, create a secondary index on EMPLOYEE CODE.

Former Member
0 Kudos

HI Arun,

In order to provide performance in SAP we use more than 1 primary key, primary key maintains index.

Regards,

Prasad

Former Member
0 Kudos

Hi,

To correctly say, SAP allows only one Primary Key on a table.But it allows to create more than one index on a table.

Primary Key: A combination of field(s) to uniquely identify a record in a table.Also known as primary index.

Index: Indexes are used to improve the performance while retrieving the data(records) from DB table.

Normally records will be arranged in a certain order in the table along with the index name if an index is created on certain field(s). If the fields specified in the index is used to query the table, then data retrieval will be fast.

In case, if one does not have a primary key fields to query the table,then he can consider using the fields specified in the index to retrieve the records.

Hope this helps.

Regards,

Dilli

Former Member
0 Kudos

Hi Arun,

In SAP also you can have only one primary key. Primary key means a field or combination of fileds which uniqely identify a record in a table. That means a primary can be created basedon a single or a combination of one or more (less than 16) fileds. in your case the table has got a primary key which is a combiantion of employ code and access code. So the combiantion 1000 AA, 1000 AB, 1001AA are different key combinations. Thats is why your table is accepting same emplloy code for different records. Hope it clears your doubt.

Regards,

Aby Chacko

Reward if helpful