当前位置:网站首页>Kingbasees SQL language reference manual of Jincang database (8. Function (I))
Kingbasees SQL language reference manual of Jincang database (8. Function (I))
2022-07-23 10:25:00 【Thousands of sails passed by the side of the sunken boat_】
8. function
Functions are similar to operators , Because they manipulate data items and return results . Functions differ from operators in parameter format . This format enables them to zero 、 One 、 Operate with two or more parameters :
function ( Parameters , Parameters ,...) Functions without any parameters are similar to pseudo columns . however , Pseudo columns usually return different values for each row in the result set , Functions without any parameters usually return the same value for each row . This chapter contains the following sections :
8.1. About SQL function
SQL The function is built into KingBase In the database , It can be used in various appropriate SQL sentence . Don't put SQL Functions and use PL/SQL User defined functions written are confused .
If the SQL The data type of the parameter of the function is the same as SQL The data type expected by the function is different , that KingBase Will be in execution SQL Function before trying to convert the parameter to the expected data type .
SQL Null value in function
Most scalar functions are given null Parameter null. You can use the NVL Function is happening null Returns a value . for example , If it is empty , Expression NVL(commission_pct,0) return 0, If commission_pct Not empty , Then return to Value commission_pct.
Information about how aggregate functions handle null values , See aggregate functions .
SQL Syntax of functions
stay SQL In the syntax diagram of the function , Parameters are represented by their data types . When parameters function Appear in the SQL Grammatical middle tense , Replace it with one of the functions described in this section . Functions are grouped by the data types of their parameters and return values .
take SQL Function applied to LOB Column time ,KingBase The database will be SQL and PL/SQL Create temporary during processing LOB. You should ensure that the temporary table space quota is sufficient to store these temporary for your application LOB.
SQL Functions may be sensitive to collations , This means that the character value comparison or matching it performs is controlled by the collation . The specific collation used by the function is determined by the collation of the function parameters .
If SQL The result of the function has a character data type , Then the collation derivation rule defines the collation to associate with the result .
The following is true of Kingbases The functions in the database are classified according to their purposes , Then the usage of each function 、 function 、 Use examples to illustrate .
8.2. Mathematical functions
The following table shows the KingbaseES Available mathematical functions . In the table ,
dpExpressdouble precision. Many of these functions have many different forms , The difference is that the parameters are different . Unless otherwise specified , Any particular form of function returns the same data type as its arguments . Handledouble precisionMost functions of data are in the host system C Library ; therefore , The accuracy and behavior of boundary cases vary according to the host system .A function used to generate random numbers .
The following table shows the available trigonometric functions . All trigonometric functions have the type
double precisionParameters and return types of . Every trigonometric function has two variants , An angle measured in radians , The other measures angle by angle .The following table shows the available hyperbolic functions . The types of parameters and return values of all these functions are
double precision.
8.3. String function
This section describes the functions used to check and manipulate string values . Strings in this environment include all types
character、character varyingandtextValue . Unless otherwise stated , All the functions listed below can handle these types , But be careful , In the use ofcharacterWhen it comes to type , It has the potential to automatically fill in blanks . Some functions can also handle bit string types .SQL Defines some string functions , They use keywords , Instead of separating parameters with commas . Please refer to the table below for details ,KingbaseES Versions of these functions using normal function call syntax are also provided .
Be careful
Due to the existence from those data types to
textImplicit enforcement of , stay KingbaseES V8.3 Before , These functions can also accept a variety of non string data types . These enforcement measures have been removed in the current version , Because they often lead to surprising behavior . however , String concatenation operator (||) Still accept non string input , As long as at least one input is a string type , As shown in the following table . In other cases , If you need to copy the previous behavior , It can be fortextInsert an explicit enforcement . about||The operator , Support the input of several spaces or newline characters between two characters , The effect is the same as without spaces or line breaks .
8.4. Binary string function
This section describes the types of inspections and operations that are bytea A function of the value of .
SQL Defines some string functions that use keywords instead of commas to separate parameters . Please refer to the table below for details .KingbaseES Versions of these functions using regular function call syntax are also provided .
Be careful
The example results shown on this page assume server parameters bytea_output Set to escape( Tradition KingbaseES Format ).
8.5. Pattern matching function
This section describes KingbaseES Support POSIX Regular expression pattern matching function .
8.6. Data type formatting function
KingbaseES Formatting functions provide a powerful set of tools for integrating various data types ( date / Time 、 Integers 、 floating-point 、 Numbers ) Convert to a formatted string and vice versa . The following table lists these functions . These functions follow a common call specification : The first parameter is the value to be formatted , The second is a template that defines the output or input format .
8.7. Time date function
The following table shows the dates that can be used to process / Function of time value , The details are described in the following sections . And demonstrates the basic arithmetic operators (
+、*etc. ) act . Functions related to formatting , You can refer to Data type formatting function . You should be familiar with Date time type Date in / Background knowledge of time data types .All acceptances described below
timeortimestampThere are actually two variants of input functions and operators : A receptiontime with time zoneortimestamp with time zone, Another kind of acceptancetime without time zoneperhapstimestamp without time zone. In order to simplify the , These variants have not been shown independently . Besides ,+and*Operators are interchangeable operator pairs ( for example ,date + integer and integer + date); We only show one .
8.8. Enumeration support functions
There are functions that allow cleaner coding for enumerated types , There is no need to write a specific value for an enumeration type . They are listed in the following table in .
8.9. Geometric functions
Geometric type
point、box、lseg、line、path、polygonandcircleThere are a lot of local support functions , As shown in the following list .
8.10. Network address function
The following table shows all that can be used for
cidrandinetFunction of type . functionabbrev、hostIt is mainly used to provide optional display formats .
8.11. XML function
The functions described in this section and the expressions of class functions are in type
xmlOperation on the value of .Used in values and type
xmlExpressions of class functions converted betweenxmlparseandxmlserializeDon't repeat here .
8.12. JSON function
This section describes how to process and create JSON Functions of data .
8.13. Sequence operation function
This section describes the operation Sequence object Function of , Sequence objects are also called sequence generators or sequences . Sequence objects are usually used to generate unique identifiers for rows in a table . These sequence functions are listed in the following table , It can provide a simple way for us to obtain continuous sequence values from sequence objects 、 Methods of multi-user security .
8.14. Array function
The following table shows the functions that can be used for array types .
8.15. Range function
The following table shows the functions available for range types
8.16. Aggregation function
Aggregation function Calculate a single value from a set of input values . stay SELECT Nested calls of aggregate functions are supported in the statement ,SELECT Only one level of aggregate function nesting is supported in the list , The query statement must contain GROUP BY Clause .
8.17. Window function
Window function Provides the ability to perform calculations on a set of rows related to the current query row .
The following table lists the built-in window functions . Note that these functions must be called using the syntax of window functions ; One
OVERClause is required .Outside these functions , Any built-in or user-defined generic or statistical aggregation ( That is, unordered sets and hypothetical sets ) Can be used as a window function , See Aggregation function . Only if the aggregate function call is followed by a
OVERWhen clause , The aggregate function will work like the window function , Otherwise, they will run in a non window aggregation manner and return a single row for the entire collection .
8.18. Set return function
This section describes functions that may return more than one line . At present, the series generating function is the most widely used in this class . Other more specific set return functions are described elsewhere in this manual .
8.19. System information function
The following table shows several functions that can extract session and system information .
In addition to the functions listed in this section , Some functions related to statistical system also provide system information .
HAS_FOREIGN_DATA_WRAPPER_PRIVILEGE
SYS_GET_FUNCTION_IDENTITY_ARGUMENTS
8.20. System management functions
The functions described in this section are used to control and monitor a KingbaseES install . Including configuration setting function 、 Server signal function 、 Backup control function 、 Restore the control function 、 Database object management function 、 Index maintenance function 、 General file access function, etc . See the table below :
边栏推荐
- LeetCode每日一题(1946. Largest Number After Mutating Substring)
- GNN third party Library: pyg (pytorch geometric) [the library based on pytorch can help users quickly build and train their own graph neural network model] [deepwalk, line, GCN, gat, etc.]
- The technical points of the new project can be guided if necessary
- C language file operation
- How to classify the same field values in a list under the same list
- Time series - third party Library: tsfresh [feature extraction, feature selection]
- MySQL queries all table names and column information of the database through SQL
- 如何将list中相同字段值归类在同一个list下
- [learning notes] graph theory thinking problem
- 时间序列-数据集:电力变压器数据集 (ETDataset)
猜你喜欢

仅用5000行代码,在V853上AI渲染出一亿幅山水画

使用IDEA的反编译插件 反编译jar包/class文件/修改jar包

Read write barrier in memory barrier -- concurrency problem

MD5加密解密网站测试,MD5加密还安全吗?

Redis安装

S2SH+mysql的在线英语学习系统

什么是文件管理软件?你为什么需要它?

Practice of online problem feedback module (11): realize image download function

Seven sorts -- detailed explanation of ten thousand words
![[basics of C language] 14 file, declaration and format input and output](/img/92/e7a9ec9e39349757f78aed4f5a622a.jpg)
[basics of C language] 14 file, declaration and format input and output
随机推荐
mysql通过sql查询数据库所有表名称及列信息
软考 系统架构设计师 简明教程 | 逆向工程
Redis token record user login design solution?
【C语言基础】16 可变数组(数组长度可扩展)
Underlying mechanism of pointer
Self organization is the two-way rush of managers and members
[learning notes] agc022
How to build and use redis fragment cluster
Langue C - quelques exercices classiques de langue C
Anaconda 换源以及安装opencv
禅道的甘特图功能是什么
Undo log日志详解
[MySQL] cursor
Time series - third party Library: tsfresh [feature extraction, feature selection]
EasyCVR平台CGO回放回调参数缺失导致设备录像无法播放,该如何解决?
Advantages and disadvantages of RDB and AOF
How does the browser import and export | delete bookmarks? Here are the steps
如何将list中相同字段值归类在同一个list下
Network communication principle and IP address allocation principle. The seven layers of the network are physical layer, data link layer, network layer, transmission layer, session layer, presentation
在线问题反馈模块实战(十一):实现图片下载功能