转载: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. 使用js 文件参数 以及IHttpModule实现服务验证asp.net 版的初步实现

    接上面的文章,上面的主要是进行html 页面自己进行处理.但是对于进行asp.net 的开发者以及其他的就显的不太好了. 我的实现方式是使用IHttpModule 进行对于用户请求的带有参数的js文件 ...

  2. CSS Grid布局入门

    相信大家都比较熟悉flex布局了,最近有空研究了波grid布局,感觉虽然兼容性还不是太高,应用不是太普遍,但是功能非常强大.未来应该是grid+flex为主流,grid是二维布局,很灵活,适合整体构架 ...

  3. HA 高可用mysql集群

    注意问题: 1.保持mysql用户和组的ID号是一致的: 2.filesystem 共享存储必须要有写入权限: 3.删除资源必须先删除约束,在删除资源: 1.安装数据库,这里使用maridb数据库: ...

  4. mysql分区表之三:MySQL分区建索引[转]

    介绍 mysql分区后每个分区成了独立的文件,虽然从逻辑上还是一张表其实已经分成了多张独立的表,从“information_schema.INNODB_SYS_TABLES”系统表可以看到每个分区都存 ...

  5. ASP.NET Web Pages:文件夹

    ylbtech-.Net-ASP.NET Web Pages:文件夹 1.返回顶部 1. ASP.NET Web Pages - 文件夹 本章介绍有关文件夹和文件夹路径的知识. 在本章中,您将学到: ...

  6. 【整理总结】代码沉淀 - CefSharp - 比较流行的第三方内嵌浏览器组件

    .NET (WPF and Windows Forms) bindings for the Chromium Embedded Framework web: https://github.com/ce ...

  7. ROS-PCQ基于IP的限速(总带宽上下行5M)

    /ip firewall mangle add chain=forward src-address=192.168.0.0/16 \ action=mark-connection new-connec ...

  8. KuDu论文解读

    kudu是cloudera在2012开始秘密研发的一款介于hdfs和hbase之间的高速分布式存储数据库.兼具了hbase的实时性.hdfs的高吞吐,以及传统数据库的sql支持.作为一款实时.离线之间 ...

  9. php mysql_db_query()函数使用介绍

    php mysql_db_query()函数选择一个数据库并在其上执行查询,本文章向大家介绍mysql_db_query()函数的基本使用方法和实例,需要的朋友可以参考一下本文章. mysql_db_ ...

  10. 更新OpenSSH

    1.安装必要组件: yum install -y gcc openssl-devel pam-devel rpm-build 2.下载OpenSSH最新版本: https://ftp.openbsd. ...