转载:http://blog.sina.com.cn/s/blog_498610450101kbxl.html

     tables: csks.

     start-of-selection.

       select * up to  rows from csks

                              where kokrs <> space and

                                    kostl <> space

                              %_hints oracle 'index(csks"J")'.

       write: / csks.

     endselect.  

ABAPSQL语句,指定索引(oracle)

①常用的两种方法:

1、指定使用全表扫描:%_HINTS ORACLE 'FULL(table_name)'

表示扫描整个表

2、指定索引:%_HINTS ORACLE 'INDEX("table_name" " index_name") '

表示扫描索引表

在SQL语句优化过程中,经常会用到hint。

Using secondary indexes

Consider the following example:

SELECT * FROM SPFLI %_HINTS ORACLE 'INDEX("SPFLI" "SPFLI~001")' ....... ENDSELECT.

In the above example, 001 is the secondary index of the table SPFLI. It's a well-known fact that the efficient way of retrieving data from the database tables is by using secondary indexes. Many database vendors provide the optimizer hints for the same. From SAP v4.5, optimizer hints can be provided by the %_HINTS parameter. This is dependent on the database systems that support optimizer hints. The point to be noted here is these optimizer hints are not standardized by the SQL standards. Each database vendor is free to provide the optimizer hints.

Now to know which index to use for our table:

1. Go to SE11 and there specify the table name

2. Now from the menu, goto --> indexes

3. select the required index.

Now suppose that the identifier 001 represents a non-unique secondary index comprising of the columns CITYFROM and CITYTO. The index name should be defined as:

~ like SPFLI~001 in the above example.

The sequence of fields in the WHERE condition is of no relevance in using this optimizers index. If you specify hints incorrectly, ABAP ignores them but doesn't return a syntax error or runtime error.

The code was written in R/3 4.6C.

Code

Consider the following example:

REPORT Suresh_test. TABLES: spfli. DATA : t_spfli LIKE spfli OCCURS 0 WITH HEADER LINE. SELECT * FROM spfli INTO TABLE t_spfli %_HINTS ORACLE 'INDEX("SPFLI" "SPFLI~001")'. LOOP AT t_spfli. WRITE :/ t_spfli. ENDLOOP.

ABAP--如何在SELECT语句中指定索引(example)

report z_generic_test_program .

tables: csks.

start-of-selection.

select * up to 10 rows from csks

where kokrs <> space and

kostl <> space

%_hints oracle 'index(csks"J")'.

write: / csks.

endselect.

Control over FOR ALL ENTRIES Hints

Under the heading Database Interface Hints, Note 129385 describes the options you have for influencing the database interface by entering hints. The hints are evaluated in the database interface itself and are not passed on to the database.

Starting with kernel Release 4.6B all the above mentioned FOR ALL ENTRIES parameters can be set via such a hint for a single statement. In the example:

SELECT * FROM [..] FOR ALL ENTRIES IN [..] WHERE [..]

%_HINTS ORACLE '&prefer_in_itab_opt 1&&prefer_fix_blocking -1&'.

This way, the boolean parameter 'prefer_in_itab_opt' is explictly set and the boolean parameter 'prefer_fix_blocking' is set to its default value.

FOR ALL ENTRIES hints, like hints are generally only used as

ABAP-索引的更多相关文章

  1. ABAP-Keyword Documentation

    转载:https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abenabap.htm ABAP - 关键字文档 本文档描述了ABAP语言 ...

  2. ABAP中SQL语句,指定索引(oracle)

    ①常用的两种方法: 1.指定使用全表扫描:%_HINTS ORACLE 'FULL(table_name)' 表示扫描整个表 2.指定索引:%_HINTS ORACLE 'INDEX("ta ...

  3. ABAP开发顾问必备:SAP ABAP开发技术总结

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  4. 优化ABAP性能(摘录)

    1.使用where语句不推荐Select * from zflight.Check : zflight-airln = ‘LF’ and zflight-fligh = ‘BW222’.Endsele ...

  5. ABAP 表格控制(Table Control)和步循环

    表格控制(Table Control)和步循环     1.两个标准Demo: SAPMTZ60,SAPMTZ61 2.简介 3.建立Table Control程序的基本流程 4.使用步循环 5.表格 ...

  6. ABAP程序系统字段中英文详解

    SY-SUBRC: 系统执行某指令后,表示执行成功与否的变量,’0’ 表示成功SY-DBLNT: 被处理过的记录的笔数 SY-UNAME: 当前使用者登入SAP的USERNAME;SY-DATUM: ...

  7. ABAP:SAP报表性能的优化

    大部分ABAPer都是从SAP报表及打印开始学起的,大家也都认为写个SAP报表程序是最简单不过的事了. 但是实际情况真的如此吗?写报表时除了保证数据的准确性,您可曾考虑过报表的性能问题吗? 由于报表程 ...

  8. ABAP 内表 详解

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  9. 字符串处理:ABAP中的正则表达式

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  10. ABAP基本数据类型、通用类型

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

随机推荐

  1. 如何取出word文档里的图片

    在生活当中,Word办公是必不可少的.但是在工作中也会遇到一些麻烦,比如说如何取出word文档里的图片呢?有的人会通过复制粘贴,通过画图保存,可是这种方法未免太繁琐了吧.下面我就来分享一下我的经验. ...

  2. Spring插件3.8.2的安装

    主机环境:win8 64bit eclipse版本:4.5.2 MARS 插件版本:Spring Tool Suite3.8.2 安装过程:直接在线安装,没有先在官网把插件下载再安装. 主要步骤: 1 ...

  3. 使用 Python 连接到 PADS Layout

    使用 Python 连接到 PADS Layout PADS Layout 使用的是 VBA 编程,很多人说 VBA 很简单,但是实在学不会,可能是太笨了. 后来发现 PADS Layout 有 CO ...

  4. ORA-32004 的错误处理

    启动数据库时,收到了ORA-32004 的错误,错误多是一些过时且在当前版本中不在使用的参数,如果碰到类似的错误,只需要将其 reset即可. SQL> startup;ORA-32004: o ...

  5. Yarn、MapReduce、spark、storm的关系

    YARN并不是下一代 MapReduce (MRv2),下一代 MapReduce 与第一代 MapReduce (MRv1)在编程接口.数据处理引擎(MapTask和ReduceTask)是完全一样 ...

  6. AppBox Mvc数据库初始化

    下载AppBoxMvc后,以为CTRL_F5运行后就能数据库初始化了.一直报失败 我的环境是VS2017,利用VS2017自带的数据库 后修改: 1.  修改AppBoxContext.cs publ ...

  7. jquery编辑插件tinyMCE的使用方法

    jquery编辑插件tinyMCE是一个非常容易集成到您系统的一个html编辑插件,它不像FckEditor那样需要针对专门的后台语言集成,tinyMCE既能做到轻松集成asp.net,php,jav ...

  8. linux 守护进程(daemon process)代码-详细注释

    1. 进程组 组长不能创建新的 会话. 其它进程可以创建新的会话,创建后既成为会话首领,同时失去控制终端. 2. 会话首领可以重新打开控制终端 1 #include <stdio.h> 2 ...

  9. winform 控件没有Cursor属性时的处理办法

    开发程序时,有时我们需要鼠标滑过空件时鼠标变成手型,这样触发动作更为贴近实际.但是有的控件不存在Cursor这个属性,就需要我们自己实现. 具体方法: /// <summary> /// ...

  10. 开发框架-开发组合:LAMP(Web应用软件组合)

    ylbtech-开发框架-开发组合:LAMP(Web应用软件组合) LAMP是指一组通常一起使用来运行动态网站或者服务器的自由软件名称首字母缩写. 1.返回顶部 1. 中文名:lamp 外文名:lam ...