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

How to write the query using Index

Former Member
0 Likes
929

Hi All,

I have to fetch the records from Database table using Index, how can i write the query using Index. Can any body plz send me the sample code.

Help Me,

Balu.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
880

Hello Bala,

You donot need to specify the index in your select statement. Just include the fields on which the index is created in the where clause of the select statement, The optimizer will choose the appropriate index at run-time so as to optimize the performance.

Regards,

Manoj

Hi All,

I have to fetch the records from Database table using Index, how can i write the query using Index. Can any body plz send me the sample code.

Help Me,

Balu.

7 REPLIES 7
Read only

Former Member
0 Likes
880

Hi,

See the below Example.

select * from vbak up to 100 rows

into table t_vbak

where vbeln > v_vbeln.

sort t_vbak by vbeln descending.

read table t_vbak index 1.

Regards,

Ram

Pls reward points if helpful.

Read only

0 Likes
880

Hi All,

I have to give the Index in the select query only when i am retrieving the data from database table, how to write the query , can any body send me th code.

Balu.

Read only

Former Member
0 Likes
881

Hello Bala,

You donot need to specify the index in your select statement. Just include the fields on which the index is created in the where clause of the select statement, The optimizer will choose the appropriate index at run-time so as to optimize the performance.

Regards,

Manoj

Read only

Former Member
0 Likes
880

when we creating the table, primary index will creeated automatically. Other than this we can created the secondary indexes. so we writing the select query, the sap itself will select the correct index with respect to the fields u specified in the select query

Read only

0 Likes
880

Hi All,

I am having indexes on the database table, can i use those indexes in the select query, how to write that,

Help me,

Balu.

Read only

0 Likes
880

Just specify the fields on which those indexes are created in the where clause of the select statement. The optimizer will choose the best index at run-time. You will not be able to specify an index EXPLICITLY with the select statement.

Hope this helps.

Manoj

Read only

0 Likes
880

check the fields that is specified in the index. after that use that field in the select query. so sap will take that index only