postgreSQL常用函数

来源:互联网 发布:怎么用蓝牙传mac文件 编辑:程序博客网 时间:2024/05/17 01:47
 postgreSQL常用函数跟oracle差不多,以下列举了几个:
•string || string: 字串连接(注:如果其中一个为空,结果也为空);
•coalesce('beautiful',0) :如果字符串为null,则转换成0表示;
•lower(string): 把字串转化为小写;
•substring(string [from int] [for int]): 抽取子字串;
•trim([leading | trailing | both] [characters] from string):从字串 string 的 开头/结尾/两边/ 删除只包含 characters (缺省是一个空白)的最长的字串
•upper(string):把字串转化为大写;
•initcap(text):把每个单词的第一个子母转为大写,其它的保留小写;
•length(string text):string 中字符的数目;
•repeat(string text, number int):重复 string number 次;
•replace(string text, from text, to text):把字串string里出现地所有子字串 from 替换成子字串 to;
•abs(x):绝对值;
•mod(y, x):除法 y/x 的余数(模);
•round(v numeric, s int):圆整为s位小数数字;
•round(dp 或者 numeric):圆整为最接近的整数;
•trunc(v numeric, s int):截断为 s 小数位置的数字;
•trunc(dp 或者 numeric):截断(向零靠近);
•to_char(?, text):转换为字符串;
•to_date(text, text):把字符串转换成日期;
•to_timestamp(text, text):把字串转换成时间戳;
•to_number(text, text):把字串转换成 numeric;
•now():当前的日期和时间;
 
原创粉丝点击