在ABAP的SQL语句中写Oracle Hints

①用过的两个写法:

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

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

其他Oracle Hints的写法可以参见这篇文章:Oracle Hint的用法

在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:

           <tablename>~<Index Identifier>
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 spfliINTO 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 a a corrective device in emergency situations; Note 129385 goes into this. The hints described here should only be used with careful consideration. 

在ABAP的SQL语句中写Oracle Hints相关推荐

  1. oracle中删除表字段 sql语句怎么写,oracle使用sql语句增加字段示例(sql删除字段语句)...

    添加字段的语法:alter table tablename add (column datatype [default value][null/not null],-.); 修改字段的语法:alter ...

  2. oracle查询表字段sql语句怎么写,oracle联合查询并更新一个表字段的sql语句

    更新某一个字段写起来简单,也容易理解: UPDATE tablea A SET A.name=(select name from tableb B where A.id=B.id) 更新多个字段就显得 ...

  3. 【C# .NET】Oracle数据库连接的坑之传入parameters参数名SQL语句中的参数变量名不匹配(顺序不一致)的问题

    问题描述 有一个user表,需要修改id为10086的用户的姓名和年龄,在C#的后台这样写: using (IDbConnection db = DapperFactory.GetConnection ...

  4. oracle sql 符号,Oracle的SQL语句中如何处理‘’符号

    Oracle的SQL语句中如何处理'&'符号 在Oracle中,如果在sql中出现'&'符号,会被自动转义: 而被要求输入在&符号后跟随的字符串的值,例如: update ta ...

  5. oracle修改表结构的sql命令是什么,sql语句中修改表结构的命令是什么?

    sql语句中修改表结构的命令是:"ALTER TABLE"命令. ALTER TABLE 语句用于在已有的表中添加.删除或修改列. SQL ALTER TABLE 语法 如需在表中 ...

  6. oracle 哦【的【,清晰讲解SQL语句中的外连接,通用于Mysql和Oracle,全是干货哦

    清晰讲解SQL语句中的外连接,通用于Mysql和Oracle,全是干货哦 直入主题: 我们做一个操作,将员工SCOTT的部门去掉,再次通过内连接查看数据,看看会产生什么现象? 使用内连接,查询数据 问 ...

  7. 转在同一个sql语句中如何写不同条件的count数量

    今天在做Portal中的Dashboard展现的时候,需要对多个统计字段做展现,根据我现在的掌握水平,我只能在sql调用构建器中实现一种sql语 句返回的resultSet做展现.没有办法,只能从数据 ...

  8. oracle sql语句中包含‘’ 的解决方法

    oracle sql语句中包含'&' 的解决方法 参考文章: (1)oracle sql语句中包含'&' 的解决方法 (2)https://www.cnblogs.com/hm1990 ...

  9. java绑定变量怎么加_在JAVA 源程序中编写SQL语句时使用ORACLE 绑定变量

    在JAVA中的SQL 语句的编写方面,没有使用ORACLE 绑定变量,很大程度上降低了数据库的性能,表现在两个方面: 1.SQL语句硬分析(Hard Parse)太多,严重消耗CPU资源,延长了SQL ...

最新文章

  1. Spring 中 @Component、@Service 等注解如何被解析?
  2. [Android学习笔记]LinearLayout布局,剩余空间的使用
  3. 人民邮电出版社图灵公司的两本SQL Server 2005图书诚征译者
  4. java io 视频 下载_Java下载映客主播视频回放到电脑硬盘
  5. VC中使用低级音频函数WaveX播放声音文件
  6. 优达学城深度学习(之四)——jupyter notebook
  7. Linux中,Mysql安装
  8. java多张图片合成一张_利用溶图技巧把多张图片合成一张奇幻风格图片教程
  9. Ubuntu16.04 Jupyter安装(Ipython Notebook安装)
  10. 物联网的体系结构分为_初学物联网信息安全、3
  11. UE4(虚幻4)引擎下载与安装
  12. Hive 3.1.2 国内镜像下载地址
  13. 掌握这几个 Java 性能调优技巧,95%的面试必问的Java性能调优知识点,
  14. 什么是hash,什么是hash表,为什么hash表查询快
  15. 爬虫-Scrapy(二) 爬取糗百笑话-单页
  16. 1.新建laravel项目
  17. 《Python程序设计》——2.2 字符串
  18. 京东智联云能打破“强者恒强”的定律吗?
  19. beautifulsoup html内容_用python3教你任意Html主内容提取
  20. 推荐几个比较容易中的EI源刊

热门文章

  1. python 中list(列表),tupe(元组),str(字符串),dict(字典)之间的相互转换
  2. DNS污染该如何解决
  3. 读书笔记-精准努力-出身寒门改变命运
  4. 赛博大陆的城镇化思考
  5. linux下printf终端打印输出颜色控制
  6. 一个熟练程序员所具备的特质-1
  7. 智能密码钥匙查看器UkeyViewer
  8. html实现led数字效果,jQuery实现LED数字效果
  9. 知乎宣布完成2.7亿美元融资 引入前蜜芽合伙人孙伟为CFO
  10. HBase 数量统计