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

Difference

Former Member
0 Likes
1,132

Hi guys ,

I have an idea about the primary key.. but why do we use the secondary key ..... May i know the exact difference between primary and secondary key

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,067

An index can be considered a copy of a database table that has been reduced to certain fields. This copy is always in sorted form. Sorting provides faster access to the data records of the table, for example using a binary search. The index also contains a pointer to the corresponding record of the actual table so that the fields not contained in the index can also be read.

The primary index is distinguished from the secondary indexes of a table. The primary index contains the key fields of the table and a pointer to the non-key fields of the table. The primary index is created automatically when the table is created in the database.

You can also create further indexes on a table in the ABAP Dictionary. These are called secondary indexes. This is necessary if the table is frequently accessed in a way that does not take advantage of the sorting of the primary index for the access.

Have a look at below link for details:

[Indexes|http://help.sap.com/saphelp_nw70/helpdata/en/cf/21eb20446011d189700000e8322d00/frameset.htm]

I hope it helps.

Best Regards,

Vibha

Please mark all the helpful answers

7 REPLIES 7
Read only

Former Member
0 Likes
1,067

Hi,

difference between primary and secondary key

Both primary key and unique enforce uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where are unique creates a nonclustered index by default. Another major difference is that, primary key doesnu2019t allow NULLs, but unique key allows one NULL only.

Secondary keys can be defined for each table to optimize the data access via SQL statements. They can refer to any column combination and they help to prevent sequential scans over the table. Like the primary key, the secondary key can consist of multiple columns.

A secondary key is often called an index (not to be confused with B* index).

Regards,

Jagadish.

Read only

Former Member
0 Likes
1,068

An index can be considered a copy of a database table that has been reduced to certain fields. This copy is always in sorted form. Sorting provides faster access to the data records of the table, for example using a binary search. The index also contains a pointer to the corresponding record of the actual table so that the fields not contained in the index can also be read.

The primary index is distinguished from the secondary indexes of a table. The primary index contains the key fields of the table and a pointer to the non-key fields of the table. The primary index is created automatically when the table is created in the database.

You can also create further indexes on a table in the ABAP Dictionary. These are called secondary indexes. This is necessary if the table is frequently accessed in a way that does not take advantage of the sorting of the primary index for the access.

Have a look at below link for details:

[Indexes|http://help.sap.com/saphelp_nw70/helpdata/en/cf/21eb20446011d189700000e8322d00/frameset.htm]

I hope it helps.

Best Regards,

Vibha

Please mark all the helpful answers

Read only

Former Member
0 Likes
1,067

hi there...

Secondary indices or secondary databases are used to access

a primary database by a key other than the primary key.

Recall that the Supplier Number field is the primary key of

the Supplier database. In this section, the Supplier City

field will be used as a secondary lookup key. Given a city

value, we would like to be able to find the Suppliers in

that city. Note that more than one Supplier may be in the

same city.

Both primary and secondary databases contain key-value

records. The key of an index record is the secondary key,

and its value is the key of the associated record in the

primary database. When lookups by secondary key are

performed, the associated record in the primary database is

transparently retrieved by its primary key and returned to

the caller.

do reward if helpful or get back with further queries.

regards

Read only

Former Member
0 Likes
1,067

Hi,

Primary Key :

Field on which a record can be uniquely identified in a data base table is called a primary key.

Secondary Key :

When a records is searched based on other primary key then the performance is hit badly so secondary key is formed which has group of field on which we can create a index for searching. There is a button called indexes which is used to create secondary key.

Regards,

Biswanath

Read only

Former Member
0 Likes
1,067

primary key

Each database table has a primary key. The primary key is either defined by the database user or generated internally. A user-defined primary key can consist of multiple columns.

secondary key

You are able to define secondary keys for each table in order to optimize data access using SQL statements. Secondary keys can refer to any combination of columns, and they help to prevent sequential scans of the table. Like the primary key, the secondary key can consist of multiple columns.

A secondary key is often called an index (not to be confused with the B* index).

reward if helpful

regards

palak

Read only

Former Member
0 Likes
1,067

Hi sanu,

<b>1. SECONDARY INDEX.

They are generally used for faster access.</b>

EG.

In a table there are 10 fields.

1,2 are primary fields (primary index)

2. But the table is queried many times

on field number 6 (eg).

So we can create a NEW Index

(Secondary index)

only on that 6th field.

3. Due to this,

the sql will become faster

because NOW

the database will search on the

basis of secnodary index (made on 6th field)

4. Primary key is to guarantee UNIQUE records.

It also helps in fast access, if we use those fields

in where condition.

regards,

amit m.

Read only

Former Member
0 Likes
1,067

hi,

Primary index: the primary index contains key fields a table and a pointer to non-key fields of the table. The primary index is created automatically when a table is created in database and moreover you can further define reference to the primary index which are known as Secondary index.