postgres字符串常用函数整理
2013-03-05 10:12
369 查看
-- 求字符串的长度
select length(field) from table_name;
select char_length(field) from table_name;
select character_length(field) from table_name;
-- 转换字符串地大小写
select lower(field) from table_name;
select upper(field) from table_name;
-- 字符串的替换 将field从1开始,2个字符替换为字符串f 按位置替换
select overlay(field placing 'f' from 1 for 2) from table_name;
-- 字符串的替换 将field中的f全部替换为x 按词替换
select replace(field,'f','x') from table_name;
-- 字符串的替换 将field中的f按照一对一的关系替换为x
select translate(field,'f','x') from table_name;
-- 截取字符串 field从1开始,截取2个字符,第一个字符的下标为1
select substring(field from 1 for 2) from table_name;
-- 在指定位置上删除指定字符 在头、尾或者两头删除A字符
select substring(leading|trailing|both 'A' from field) from table_name;
-- 将字符串的首字母大写化
select initcap(field) from table_name;
select overlay(string placing upper(substring(string from 1 for 1)) from 1 for 1) from table_name;
-- 取得当前日期函数
select now();
-- 用一个表的数据更新另一个表的数据
update table1 set fieldName = value from table2 where condition.
-- 查找前10行数据
select * from tableName limit 10;
-- 查找10行以后的数据
select * from tableName offset 10;
相关文章推荐
- PHP 常用字符串,数组处理函数整理(一)
- lua和C#中函数string.format对字符串常用的格式化整理
- 我学PHP整理的数组与字符串常用函数
- ABAP常用字符串操作收集整理
- mysql 常用函数整理
- PHP常用的字符串格式化函数
- 一些常用函数的整理
- C++中字符串分割的常用函数
- php中常用的字符串比较函数strcmp()实例解释
- 跟我学习php字符串常用函数-下篇
- JS截取字符串常用方法详细整理
- Python中常用字符串 函数
- Delphi中常用字符串处理函数
- 实现常用字符串处理函数(不调用库函数)
- C语言常用的字符串操作函数
- 几个常用的Javascript字符串处理函数 spilt(),join(),substring()和indexof()
- php中常用的字符串格式化函数
- Python字符串常用函数
- 字符串处理的一些常用函数
- cocos2d-x 数学函数、常用宏粗整理 - by Glede