Postgresql 中文操作指南

Chapter 9. Functions and Operators

Table of Contents

PostgreSQL 为内置数据类型提供了大量的函数和运算符。本章介绍了其中的大部分内容,尽管其他专用的函数出现在手册的相关部分。用户还可以定义自己的函数和运算符,如 Part V 中所述。psql 命令 \df\do 可用于分别列出所有可用的函数和运算符。

PostgreSQL provides a large number of functions and operators for the built-in data types. This chapter describes most of them, although additional special-purpose functions appear in relevant sections of the manual. Users can also define their own functions and operators, as described in Part V. The psql commands \df and \do can be used to list all available functions and operators, respectively.

在整个本章中,用来描述函数或运算符的参数和结果数据类型的符号如下:

The notation used throughout this chapter to describe the argument and result data types of a function or operator is like this:

repeat ( text, integer ) → text

其中说明了函数 repeat 接受一个文本和一个整型自变量,并返回一个文本类型的结果。右箭头还用于指示示例的结果,形式如下:

which says that the function repeat takes one text and one integer argument and returns a result of type text. The right arrow is also used to indicate the result of an example, thus:

repeat('Pg', 4) → PgPgPgPg

如果您关心可移植性,需要注意的是本章中所述的大多数函数和运算符(除了最简单的算术和比较运算符以及一些明确标记的函数)未在 SQL 标准中指定。其他 SQL 数据库管理系统中存在一些此类扩展功能,而且在许多情况下,此类功能在各种实现之间兼容且一致。

If you are concerned about portability then note that most of the functions and operators described in this chapter, with the exception of the most trivial arithmetic and comparison operators and some explicitly marked functions, are not specified by the SQL standard. Some of this extended functionality is present in other SQL database management systems, and in many cases this functionality is compatible and consistent between the various implementations.