↑↓ 选择 ↵ 打开 ⌫ 改范围 完整检索页

pgsql.cc 提供对 postgresql.org 官网内容的中文翻译,由 Pigsty 团队维护。

百科 / 函数百科 / 7.1 变更

PostgreSQL 7.1 函数变更

7.1 是本数据集的收录基线,不代表该函数首次于 7.1 引入。本页列出 7.1 当时已有的全部 94 个函数。

换一个对比基准

7.1 的全部函数94

函数 签名 主签名 版本变动 最近变更
MATHEMATICAL FUNCTIONS AND OPERATORS 数学函数和操作符 24 个 ↗
abs基线 1 abs ( numeric_type ) → numeric_type 8.41 次
绝对值 现存
acos基线 1 acos ( double precision ) → double precision —
反余弦,结果为弧度 现存
asin基线 1 asin ( double precision ) → double precision —
反正弦,结果为弧度 现存
atan基线 1 atan ( double precision ) → double precision —
反正切,结果为弧度 现存
atan2基线 1 atan2 ( y double precision, x double precision ) → double precision 8.31 次
y/x 的反正切,结果为弧度 现存
cbrt基线 1 cbrt ( double precision ) → double precision —
立方根 现存
ceil基线 2 ceil ( numeric ) → numeric 7.31 次
大于或等于参数的最接近的整数 现存
cos基线 1 cos ( double precision ) → double precision —
余弦,参数为弧度 现存
cot基线 1 cot ( double precision ) → double precision —
余切,参数为弧度 现存
degrees基线 1 degrees ( double precision ) → double precision —
将弧度转换为角度 现存
exp基线 2 exp ( numeric ) → numeric 7.31 次
指数函数(e 的给定次幂) 现存
floor基线 2 floor ( numeric ) → numeric 7.31 次
小于或等于参数的最接近整数 现存
ln基线 2 ln ( numeric ) → numeric 7.31 次
自然对数 现存
log基线 3 log ( numeric ) → numeric 7.31 次
以 10 为底的对数 现存
mod基线 1 mod ( y numeric_type, x numeric_type ) → numeric_type —
y/x 的余数;适用于 smallint、integer、bigint 和 numeric 现存
pi基线 1 pi ( ) → double precision —
π的近似值 现存
pow基线 2 pow ( a dp, b dp ) → dp 7.42 次
a的b次幂 于 8.0 移除
radians基线 1 radians ( double precision ) → double precision —
将角度转换为弧度 现存
random基线 7 random ( ) → double precision 192 次
返回范围 0.0 <= x < 1.0 内的随机值 现存
round基线 3 round ( numeric ) → numeric 8.12 次
舍入到最接近的整数。对于 numeric,遇到恰好位于中点的情况时按远离零的方向舍入。对于 double precision,中点取舍规则取决于平台,但“舍入到最接近的偶数”是最常见的规则。 现存
sin基线 1 sin ( double precision ) → double precision —
正弦,参数为弧度 现存
sqrt基线 2 sqrt ( numeric ) → numeric 7.31 次
平方根 现存
tan基线 1 tan ( double precision ) → double precision —
正切,参数为弧度 现存
trunc基线 5 trunc ( numeric ) → numeric 103 次
向零截断为整数 现存
STRING FUNCTIONS AND OPERATORS 字符串函数和操作符 22 个 ↗
ascii基线 1 ascii ( text ) → integer 8.22 次
返回参数的第一个字符的数字代码。在 UTF8 编码中,返回该字符的 Unicode 码点。在其他多字节编码中,该参数必须是一个 ASCII 字符。 现存
btrim基线 2 btrim ( string text [, characters text ] ) → text 8.04 次
从 string 的开头和结尾移除仅由 characters 中字符(默认为空格)组成的最长字符串。 现存
char_length基线 1 char_length ( text ) → integer 8.11 次
返回字符串中的字符数。 现存
character_length基线 1 character_length ( text ) → integer 8.11 次
返回字符串中的字符数。 现存
chr基线 1 chr ( integer ) → text 8.11 次
返回给定代码的字符。在 UTF8 编码中该参数被视作一个 Unicode 码点。在其他多字节编码中该参数必须指定一个 ASCII 字符。chr(0) 字符不被允许,因为文本数据类型不能存储这种字符。 现存
initcap基线 1 initcap ( text ) → text 8.21 次
将每个单词的第一个字母转换为大写(如果该字母是二合字母,且区域设置为 ICU 或 builtin PG_UNICODE_FAST,则转换为标题大小写),其余字母转换为小写。使用 libc 或 builtin 区域设置提供者时,单词是由非字母数字字符分隔的字母数字字符序列;使用 ICU 区域设置提供者时,单词按 ICU 的 u_strToTitle 函数划分。 现存
length基线 6 length ( text ) → integer 9.16 次
返回字符串中的字符数。 现存
lower基线 3 lower ( text ) → text 142 次
根据数据库的区域设置规则,将字符串转换为全部小写。 现存
lpad基线 1 lpad ( string text, length integer [, fill text ] ) → text 8.11 次
在 string 前面添加字符 fill(默认为空格),将其填充到长度 length。如果 string 已经长于 length,则从右侧截断。 现存
ltrim基线 2 ltrim ( string text [, characters text ] ) → text 144 次
从 string 的开头移除仅由 characters 中字符(默认为空格)组成的最长字符串。 现存
octet_length基线 4 octet_length ( text ) → integer 8.11 次
返回字符串的字节数。 现存
position基线 3 position ( substring text IN string text ) → integer 8.11 次
返回 substring 在 string 中首次出现的位置;如果不存在则返回零。 现存
repeat基线 1 repeat ( string text, number integer ) → text 8.12 次
按 number 指定的次数重复 string。 现存
rpad基线 1 rpad ( string text, length integer [, fill text ] ) → text 8.11 次
在 string 后面追加字符 fill(默认为空格),将其填充到长度 length。如果 string 已经长于 length,则截断它。 现存
rtrim基线 2 rtrim ( string text [, characters text ] ) → text 143 次
从 string 的结尾移除仅由 characters 中字符(默认为空格)组成的最长字符串。 现存
strpos基线 1 strpos ( string text, substring text ) → integer 7.31 次
返回 substring 在 string 中首次出现的位置;如果不存在则返回零。(与 position(substring in string) 相同,但请注意参数顺序相反。) 现存
substr基线 2 substr ( string text, start integer [, count integer ] ) → text —
提取 string 中从第 start 个字符开始的子字符串;若指定了长度,则提取 count 个字符。(与 substring(string from start for count) 相同。) 现存
substring基线 11 substring ( string text [ FROM start integer ] [ FOR count integer ] ) → text 196 次
提取 string 的子字符串:若指定了起始位置,则从第 start 个字符开始;若指定了长度,则在提取 count 个字符后停止。start 和 count 至少需要指定一个。 现存
to_ascii基线 3 to_ascii ( string text ) → text 8.21 次
将 string 从其他编码转换为 ASCII,源编码可以用名称或编号指定。如果省略 encoding,则使用数据库编码(实际上,这也是唯一有用的情况)。转换主要是去除重音符号。只支持从 LATIN1、LATIN2、LATIN9 和 WIN1250 编码转换。(另一种更灵活的解决方案参见 unaccent 模块。) 现存
translate基线 1 translate ( string text, from text, to text ) → text —
将 string 中与 from 集合中匹配的每个字符替换为 to 集合中相应的字符。如果 from 长于 to,输入中出现的 from 中的额外字符会被删除。 现存
trim基线 4 trim ( [ LEADING | TRAILING | BOTH ] [ characters text ] FROM string text ) → text 144 次
从 string 的开始、末端或两端(默认为 BOTH)移除仅包含 characters(默认为空格)字符的最长字符串。 现存
upper基线 3 upper ( text ) → text 142 次
根据数据库的区域设置规则,将字符串转换为全部大写。 现存
DATA TYPE FORMATTING FUNCTIONS 数据类型格式化函数 4 个 ↗
to_char基线 4 to_char ( timestamp, text ) → text 7.21 次
根据给定的格式将时间戳转换为字符串。 现存
to_date基线 1 to_date ( text, text ) → date —
根据给定的格式将字符串转换为日期。 现存
to_number基线 1 to_number ( text, text ) → numeric —
根据给定的格式将字符串转换为数值。 现存
to_timestamp基线 2 to_timestamp ( text, text ) → timestamp with time zone 8.12 次
根据给定的格式将字符串转换为时间戳。(也请参见表 9.33 中的 to_timestamp(double precision)。) 现存
DATE/TIME FUNCTIONS AND OPERATORS 日期/时间函数和操作符 9 个 ↗
age基线 3 age ( timestamp, timestamp ) → interval —
将两个参数相减,生成一个使用年和月而不是只用日的“符号化”结果 现存
current_timestamp基线 3 current_timestamp → timestamp with time zone 8.23 次
当前日期和时间(当前事务开始时);参见第 9.9.5 节 现存
date_part基线 3 date_part ( text, timestamp ) → double precision —
获取时间戳子字段(等同于 extract);参见第 9.9.1 节 现存
date_trunc基线 4 date_trunc ( text, timestamp ) → timestamp 183 次
截断到指定的精度;参见第 9.9.2 节 现存
extract基线 3 extract ( field FROM timestamp ) → numeric 193 次
获取时间戳子字段;参见第 9.9.1 节 现存
isfinite基线 3 isfinite ( date ) → boolean 8.41 次
测试日期是否有限(不是正负无穷) 现存
now基线 2 now ( ) → timestamp with time zone 8.22 次
当前日期和时间(当前事务开始时);参见第 9.9.5 节 现存
timeofday基线 2 timeofday ( ) → text 8.21 次
当前的日期和时间(类似 clock_timestamp,但是采用 text 字符串);参见第 9.9.5 节 现存
timestamp基线 2 timestamp ( date ) → timestamp —
date 转换为 timestamp 于 7.3 移除
GEOMETRIC FUNCTIONS AND OPERATORS 几何函数和操作符 17 个 ↗
area基线 1 area ( geometric_type ) → double precision —
计算面积。适用于 box、path、circle。path 输入必须封闭,否则返回 NULL。同样,如果 path 是自交叉的,结果可能是没有意义的。 现存
box基线 4 box ( circle ) → box 9.52 次
计算内接于圆的矩形框。 现存
center基线 1 center ( geometric_type ) → point —
计算中心点。适用于 box、circle。 现存
circle基线 3 circle ( box ) → circle 8.11 次
计算包围矩形框的最小圆。 现存
diameter基线 1 diameter ( circle ) → double precision —
计算圆的直径。 现存
height基线 1 height ( box ) → double precision —
计算框的垂直尺寸。 现存
isclosed基线 1 isclosed ( path ) → boolean —
路径是否封闭? 现存
isopen基线 1 isopen ( path ) → boolean —
路径是否开放? 现存
lseg基线 2 lseg ( box ) → lseg —
提取框的对角线作为线段。 现存
npoint基线 1 npoint ( path ) → integer 7.21 次
点数 于 7.3 移除
path基线 1 path ( polygon ) → path 8.31 次
将多边形转换为具有相同点列表的封闭路径。 现存
pclose基线 1 pclose ( path ) → path —
将路径转换为封闭形式。 现存
point基线 5 point ( double precision, double precision ) → point 8.12 次
从它的坐标构造点。 现存
polygon基线 4 polygon ( box ) → polygon —
将框转换为 4 点多边形。 现存
popen基线 1 popen ( path ) → path —
将路径转换为开放形式。 现存
radius基线 1 radius ( circle ) → double precision —
计算圆的半径。 现存
width基线 1 width ( box ) → double precision —
计算框的水平大小。 现存
NETWORK ADDRESS FUNCTIONS AND OPERATORS 网络地址函数和操作符 7 个 ↗
abbrev基线 2 abbrev ( inet ) → text 8.21 次
创建文本形式的缩写显示格式。(结果与 inet 输出函数产生的结果相同;只有与显式类型转换为 text 的结果相比时,才称为“缩写形式”。由于历史原因,后一种转换从不省略网络掩码部分。) 现存
broadcast基线 1 broadcast ( inet ) → inet —
为地址的网络计算广播地址。 现存
host基线 1 host ( inet ) → text —
返回 IP 地址文本,忽略子网掩码。 现存
masklen基线 1 masklen ( inet ) → integer 8.11 次
返回子网掩码长度,以位为单位。 现存
netmask基线 1 netmask ( inet ) → inet —
为地址的网络计算网络掩码。 现存
network基线 1 network ( inet ) → cidr —
返回地址的网络部分,将子网掩码右边的部分归零。(这相当于将值转换为 cidr。) 现存
text基线 1 text ( inet ) → text —
以文本形式返回未缩写的 IP 地址和子网掩码长度。(这与显式转换为 text 的结果相同。) 现存
CONDITIONAL EXPRESSIONS 条件表达式 2 个 ↗
COALESCE基线 1 COALESCE(value [, ...]) 7.31 次
COALESCE 函数返回参数中第一个不为 null 的值。只有所有参数都为 null 时,才返回 null。它常用于在检索数据以供显示时,用默认值替换 null 值。例如: 现存
NULLIF基线 1 NULLIF(value1, value2) —
当 value1 和 value2 相等时,NULLIF 返回 null。否则它返回 value1。这可以用于执行前文给出的 COALESCE 示例的逆操作: 现存
AGGREGATE FUNCTIONS 聚合函数 7 个 ↗
avg基线 7 avg ( smallint ) → numeric 8.42 次
计算所有非空输入值的平均值(算术平均值)。 现存
count基线 2 count ( * ) → bigint 7.32 次
计算输入行的数量。 现存
max基线 1 max ( see text ) → same as input type 7.32 次
计算非空输入值的最大值。适用于任何数字、字符串、日期/时间或枚举类型,以及 bytea、inet、interval、money、oid、oid8、pg_lsn、tid、uuid、xid8,以及包含可排序数据类型的数组和复合类型。 现存
min基线 1 min ( see text ) → same as input type 7.32 次
计算非空输入值的最小值。适用于任何数字、字符串、日期/时间或枚举类型,以及 bytea、inet、interval、money、oid、oid8、pg_lsn、tid、uuid、xid8,以及包含可排序数据类型的数组和复合类型。 现存
stddev基线 1 stddev ( numeric_type ) → double precision for real or double precision, otherwise numeric 7.32 次
这是 stddev_samp 的一个历史别名。 现存
sum基线 8 sum ( smallint ) → bigint 9.04 次
计算非空输入值的总和。 现存
variance基线 1 variance ( numeric_type ) → double precision for real or double precision, otherwise numeric 7.32 次
这是 var_samp 的一个历史别名。 现存
SYSTEM INFORMATION FUNCTIONS AND OPERATORS 系统信息函数和操作符 2 个 ↗
current_user基线 1 current_user → name —
返回当前执行上下文的用户名。 现存
session_user基线 1 session_user → name —
返回会话用户名。 现存