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: 

QUESTION ON OPEN SQL.

Former Member
0 Kudos

whenever we access data from the data base using SELECT STATEMENT then it will be processed by primary index but if i want to use secondary (i have created secondary index field) what will be my syntax in the programming 4 secondary index field?

5 REPLIES 5

Sandeep_Kumar
Product and Topic Expert
Product and Topic Expert
0 Kudos

Please close the multiple threads.

Former Member
0 Kudos

hi Ramesh,

Your select statement will not always process thru the primary index.

1. Primary index iscreated by default, when you activate a table and is associated with the key fields specified while creating the table.

2. Your query will hit the primary index only if you mention all the key fields in your select statement.

3. You can create a (or more ) secondary index if your select statement cannot mention all the keyfields, in the primary index.

4. After creating the secondary index, as per the requirement (query requirement), you can use the fields mentioned in your secondary index in your select statement.

This time, the select statement will process the secondary index created by you..

Hope this helps.

Sajan.

Former Member
0 Kudos

Hi Ramesh,

1. the primary index is automatically created based on the primary key of your table.

2. To optimize the performance of the query, we creates the secondary indexes for the fields which are most and frequently used in the where clause.

3. Then the selection of index based on the fields in the where clause is done by Database optimizer.

4. we never explicilty specify which index to use.

Former Member
0 Kudos

just as in the other answers the secondary index is s'th what we mention in the where clause and there would be no big change in the syntax of the select statement.

select <f1> <f2> from DB1 into table itab

where <cond1>

<cond2>.

Former Member
0 Kudos

Hi,

If you are not using the primary index/Primary keys in selection of data,based on the where condition and the key used your secondary index will be used if it has been created.

So it's like :

--> If primary key is used in the where conditions using select we use the primary index.

-


> else if the primary index is not a part of where condition and it has been created as secondary index,it will be used.

Thanks,

Rajesh Sahal