ABAP中SQL语句,指定索引(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 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)的更多相关文章
- oracle中sql语句的优化
oracle中sql语句的优化 一.执行顺序及优化细则 1.表名顺序优化 (1) 基础表放下面,当两表进行关联时数据量少的表的表名放右边表或视图: Student_info (30000条数据)D ...
- Oracle ------ SQLDeveloper中SQL语句格式化快捷键
Oracle SQL Developer中SQL语句格式化快捷键: 每次sql复制到SQL Developer面板的时候,格式老不对,而且看起来很不舒服,所有的sql都挤在一行完成. 这时我们可以全选 ...
- Oracle SQL Developer中SQL语句格式化快捷键
Oracle SQL Developer中SQL语句格式化快捷键 格式化SQL语句:Ctrl+F7
- Oracle中SQL语句分类
Oracle中SQL语句分类如下:1.DML语句 insert/delete/update/select/merge/explan plan/lock table2.DDL语句 create/atlt ...
- 转:Oracle中SQL语句执行过程中
Oracle中SQL语句执行过程中,Oracle内部解析原理如下: 1.当一用户第一次提交一个SQL表达式时,Oracle会将这SQL进行Hard parse,这过程有点像程序编译,检查语法.表名.字 ...
- oracle 中SQL 语句开发语法 SELECT INTO含义
oracle 中SQL 语句开发语法 SELECT INTO含义 在ORACLE中SELECT INTO是如何使用的,什么意思?和SQL SERVER的不一样? 和sqlserver的不一样sql ...
- 跟踪oracle中sql语句运行过程及相关知识拓展
select * from v$sqlarea; select * from v$sqlarea where first_load_time>'2010-11-27/09:30:00'; 这种方 ...
- 详解Java的MyBatis框架中SQL语句映射部分的编写
这篇文章主要介绍了Java的MyBatis框架中SQL语句映射部分的编写,文中分为resultMap和增删查改实现两个部分来讲解,需要的朋友可以参考下 1.resultMap SQL 映射XML 文件 ...
- 整理:sql server 中sql语句执行顺序
SQL Server 查询处理中的各个阶段(SQL执行顺序) SQL 不同于与其他编程语言的最明显特征是处理代码的顺序.在大数编程语言中,代码按编码顺序被处理,但是在SQL语言中,第一个被处理的子句是 ...
随机推荐
- Unity 保存游戏,读取游戏,退出游戏
1 using System.Collections; 2 using System.Collections.Generic; 3 using UnityEngine; 4 using System. ...
- Docker(五):Docker安装Elasticsearch
查找ElasticSearch镜像 镜像仓库 https://hub.docker.com/ 下拉镜像 docker pull elasticsearch:7.7.0 查看镜像 docker imag ...
- <未解决的问题>crontab 定时弹框任务
问题:crontab写别的定时脚本就可以执行(比如说每隔一分钟就创建一个txt文件),但是写shell就不知道为什么,反弹不了 但是开启Linux终端窗口单独执行bash shell时候,(不通过re ...
- Spring Boot 2.4版本前后的分组配置变化及对多环境配置结构的影响
前几天在<Spring Boot 2.4 对多环境配置的支持更改>一文中,给大家讲解了Spring Boot 2.4版本对多环境配置的配置变化.除此之外,还有一些其他配置变化,所以今天我们 ...
- Python十大装B语法!你会几种?
本文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,如有问题请及时联系我们以作处理 Python 是一种代表简单思想的语言,其语法相对简单,很容易上手.不过,如果就此小视 Python ...
- .NET5 API 网关Ocelot+Consul服务注册
1|0网关介绍 网关其实就是将我们写好的API全部放在一个统一的地址暴露在公网,提供访问的一个入口.在 .NET Core下可以使用Ocelot来帮助我们很方便的接入API 网关.与之类似的库还有Pr ...
- 使用GitHub发布自己的静态网站
可参考GitHub官方文档 https://pages.github.com/ https://help.github.com/ 1.在本地新建一个文件夹.然后在文件夹中用git初始化文件夹 git ...
- [每日一题]ES6中为什么要使用Symbol?
关注「松宝写代码」,精选好文,每日面试题 加入我们一起学习,day day up 作者:saucxs | songEagle 来源:原创 一.前言 2020.12.23日刚立的flag,每日一题,题目 ...
- Spring Cloud 各个组件角色简介
概述 SpringCloud 是一个全家桶式的技术栈,包含了很多组件:包含 Eureka.Ribbon.Feign.Zuul .Hystrix等.每个组件完成对应的功能 组件介绍 - 服务发现 Eur ...
- java中token的生成和验证
package com.zjn.token; /** * token编码工具类 * @author ouyangjun */ public class TokenEncryptUtils { // 编 ...