Postgresql - Functions and Operators 函数和运算 - Enum

枚举类型的函数很少,都是查询枚举类型中的值相关。

Function

Description

Example

Example Result

enum_first(anyenum)

返回枚举中的第一个值

enum_first(null::rainbow)

red

enum_last(anyenum)

返回枚举中的最后一个值

enum_last(null::rainbow)

purple

enum_range(anyenum)

返回所有枚举值

enum_range(null::rainbow)

{red,orange,yellow,green,blue,purple}

enum_range(anyenum, anyenum)

返回两个给定枚举值之间的范围,作为有序数组。这些值必须来自同一枚举类型。如果第一个参数为NULL,结果将从枚举类型的第一个值开始。如果第二个参数为NULL,结果将以枚举类型的最后一个值结束。

enum_range('orange'::rainbow, 'green'::rainbow)

{orange,yellow,green}

enum_range(NULL, 'green'::rainbow)

{red,orange,yellow,green}

enum_range('orange'::rainbow, NULL)

{orange,yellow,green,blue,purple}

猜你喜欢

转载自blog.csdn.net/chuckchen1222/article/details/81386484