postgre 函数整理
COALESCE
COALESCE (expression_1, expression_2, ...,expression_n)依次参考各参数表达式,遇到非null值即停止并返回该值。如果所有的表达式都是空值,最终将返回一个空值。对于空值可以指定返回的默认值。
CONCAT
CONCAT(str1,str2,...)返回拼接参数的新字符串
string || string
字符串连接操作
md5(string)
对字符串md5加密
to_char
将日期、整数、浮点数等格式化为字符串
Function | Return Type | Description | Example |
---|---|---|---|
to_char(timestamp, text) | text | convert time stamp to string | to_char(current_timestamp, 'HH12:MI:SS') |
to_char(interval, text) | text | convert interval to string | to_char(interval '15h 2m 12s', 'HH24:MI:SS') |
to_char(int, text) | text | convert integer to string | to_char(125, '999') |
to_char (double precision, text) | text | convert real/double precision to string | to_char(125.8::real, '999D9') |
to_char(numeric, text) | text | convert numeric to string | to_char(-125.8, '999D99S') |
to_date(text, text) | date | convert string to date | to_date('05 Dec 2000', 'DD Mon YYYY') |
to_number(text, text) | numeric | convert string to numeric | to_number('12,454.8-', '99G999D9S') |
to_timestamp(text, text) | timestamp with time zone | convert string to time stamp | to_timestamp('05 Dec 2000', 'DD Mon YYYY') |