没有合适的资源?快使用搜索试试~ 我知道了~
SAP HANA SQL Script
4星 · 超过85%的资源 需积分: 12 16 下载量 144 浏览量
2013-05-09
17:26:28
上传
评论 1
收藏 3.61MB PDF 举报
温馨提示
试读
63页
hana_dev_sqlscript_en.sql script 开发手册
资源推荐
资源详情
资源评论
PUBLIC
SAP HANA Appliance Software SPS 05
Document Version: 1.0 - 2012-11-29
SAP HANA SQLScript Reference
Table of Contents
1 About SAP HANA SQLScript......................................................4
1.1 Backus Naur Form Notation........................................................4
1.2 What is SQLScript? ..............................................................5
1.2.1 SQLScript Processing Overview..............................................6
1.3 Datatype Extension..............................................................8
1.3.1 Scalar Datatypes.........................................................8
1.3.2 Table Types............................................................ 8
1.4 Functional Extension.............................................................8
1.4.1 Create Procedure ........................................................9
1.4.2 SQLScript Procedure......................................................9
1.4.3 Default values for procedure parameters.......................................12
1.5 Procedure Calls................................................................12
1.5.1 CALL - Procedure Called From Client..........................................13
1.5.2 CALL - Internal Procedure Call.............................................. 13
1.5.3 Call with Named Parameters................................................14
1.6 Implementing Functional Logic.....................................................15
1.6.1 Table Variables.........................................................15
1.6.2 Binding Table Variables................................................... 15
1.6.3 Scalar Variables.........................................................16
1.6.4 Referencing Variables.................................................... 16
1.7 Calculation Engine Plan Operators...................................................16
1.7.1 Data Source Access Operators..............................................17
1.7.2 Relational Operators..................................................... 21
1.7.3 Special Operators.......................................................30
1.8 Imperative Extension............................................................34
1.8.1 Scalar Variables........................................................ 35
1.8.2 Variable Scope Nesting................................................... 36
1.8.3 Control Structures.......................................................39
1.8.4 Cursors.............................................................. 43
1.8.5 Dynamic SQL..........................................................48
1.9 Catalog Information.............................................................49
1.10 Best Practices for Using SQLScript..................................................51
1.10.1 Reduce Complexity of SQL Statements ........................................51
1.10.2 Identify Common Sub-Expressions...........................................52
1.10.3 Multi-level Aggregation................................................... 52
1.10.4 Understand the Costs of Statements .........................................52
2
P U B L I C
©
2012 SAP AG. All rights reserved.
SAP HANA SQLScript Reference
Table of Contents
1.10.5 Exploit Underlying Engine..................................................53
1.10.6 Reduce Dependencies....................................................55
1.10.7 Avoid Mixing Calculation Engine Plan Operators and SQL Queries..................... 55
1.10.8 Avoid Using Cursors..................................................... 55
1.10.9 Avoid using Dynamic SQL..................................................57
1.11 Developing Applications with SQLScript.............................................. 57
1.11.1 Handling Temporary Data..................................................57
1.11.2 SQL Query for Ranking....................................................58
1.11.3 Calling SQLScript From Clients..............................................58
SAP HANA SQLScript Reference
Table of Contents
P U B L I C
©
2012 SAP AG. All rights reserved. 3
1 About SAP HANA SQLScript
SQLScript is a collection of extensions to Structured Query Language (SQL). The extensions are:
● Data extension, which allows the definition of table types without corresponding tables.
● Functional extension, which allows definitions of (side-effect free) functions which can be used to express and
encapsulate complex data flows.
● Procedural extension, which provides imperative constructs executed in the context of the database process.
1.1 Backus Naur Form Notation
This document uses BNF (Backus Naur Form) which is the notation technique used to define programming
languages. BNF describes the syntax of a grammar using a set of production rules using a set of symbols.
Symbols used in BNF
Symbol Description
< > Angle brackets are used to surround the name of a syntactic element (BNF non-terminal)
of the SQL language.
::= The definition operator is used to provide definitions of the element appeared on the left
side of the operator in a production rule.
[ ] Square brackets are used to indicate optional elements in a formula. Optional elements
may be specified or omitted.
{ } Braces group elements in a formula. Repetitive elements (zero or more elements) can be
specified within brace symbols.
| The alternative operator indicates that the portion of the formula following the bar is an
alternative to the portion preceding the bar.
... The ellipsis indicates that the element may be repeated any number of times. If ellipsis
appears after grouped elements specifying that the grouped elements enclosed with
braces are repeated. If ellipsis appears after a single element, only that element is
repeated.
!! Introduces normal English text. This is used when the definition of a syntactic element is
not expressed in BNF.
BNF Lowest Terms Representations
Throughout the BNF used in this document each syntax term will be defined to one of the lowest term
representations shown below.
<digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
4
P U B L I C
©
2012 SAP AG. All rights reserved.
SAP HANA SQLScript Reference
About SAP HANA SQLScript
<letter> ::= a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p
| q | r | s | t | u | v | w | x | y | z
| A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P
| Q | R | S | T | U | V | W | X | Y | Z
<string_literal> ::= <double_quote><string_content><double_quote> |
<single_quote><string_content><single _quote>
<string_content> = { <letter> | <digit> }...
<identifier> ::= <letter> { <letter> | <digit> }...
<password> ::= [{ <letter> | <digit> }...]
<sign> ::= + | -
<period> ::= .
<unsigned_integer> ::= <digit>...
<signed_integer> ::= [<sign>] <unsigned_integer>
<signed_numeric_literal> ::= [<sign>] <unsigned_numeric_literal>
<unsigned_numeric_literal> ::= <exact_numeric_literal> |
<approximate_numeric_literal>
<exact_numeric_literal> ::= <unsigned_integer> [<period>
[<unsigned_integer>]]
| <period> <unsigned_integer>
<approximate_numeric_literal> ::= <mantissa> E <exponent>
<mantissa> ::= <exact_numeric_literal>
<exponent> ::= <signed_integer>
1.2 What is SQLScript?
The motivation for SQLScript is to embed data-intensive application logic into the database. As of today,
applications only offload very limited functionality into the database using SQL, most of the application logic is
normally executed in an application server. This has the effect that data to be operated upon needs to be copied
from the database into the application server and vice versa. When executing data intensive logic, this copying of
data is very expensive in terms of processor and data transfer time. Moreover, when using an imperative language
like ABAP or JAVA for processing data, developers tend to write algorithms which follow a one tuple at a time
semantics (for example looping over rows in a table). However, these algorithms are hard to optimize and
parallelize compared to declarative set-oriented languages such as SQL.
The SAP HANA database is optimized for modern technology trends and takes advantage of modern hardware,
for example, by having data residing in main-memory and allowing massive-parallelization on multi-core CPUs.
The goal of the SAP HANA database is to optimally support application requirements by leveraging such
hardware. To this end, the SAP HANA database exposes a very sophisticated interface to the application
consisting of many languages. The expressiveness of these languages far exceeds that attainable with OpenSQL.
SAP HANA SQLScript Reference
About SAP HANA SQLScript
P U B L I C
©
2012 SAP AG. All rights reserved. 5
剩余62页未读,继续阅读
资源评论
- roy_xuan2016-05-20非常好的教材,谢谢您的分享!
doublezhuang
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- pta题库答案c语言之排序4统计工龄.zip
- pta题库答案c语言之树结构7堆中的路径.zip
- pta题库答案c语言之树结构3TreeTraversalsAgain.zip
- pta题库答案c语言之树结构2ListLeaves.zip
- pta题库答案c语言之树结构1树的同构.zip
- 基于C++实现民航飞行与地图简易管理系统可执行程序+说明+详细注释.zip
- pta题库答案c语言之复杂度1最大子列和问题.zip
- 三维装箱问题(Three-Dimensional Bin Packing Problem,3D-BPP)是一个经典的组合优化问题
- 以下是一些关于Linux线程同步的基本概念和方法.txt
- 以下是一个简化的示例,它使用pygame库来模拟烟花动画的框架.txt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功