ascii(string) |
int |
The ASCII code of the first character of the parameter |
ascii(‘a’) |
97 |
btrim(string text [,characters text]) |
text |
Remove the longest string containing only characters (a space by default) from the beginning or end of string |
btrim('aaosdbaa','aa') btrim('osdba','') btrim('osdba') |
osdb osdba osdba |
chr(int) |
text |
Gives the ASCII code for the character |
chr(97) |
a |
convert(string text,[src_encoding name,]dest_encoding name) |
text |
Convert the string originally encoded as src_encoding to dest_encoding (omit src_encoding to use database encoding) |
convert(‘aa’,‘UTF8’,‘GBK’) |
\x6161 |
decode(string text,type text) |
bytea |
Decode the binary data in the string originally encoded with encode, and the parameter type is the same as encode |
decode(‘b3NkYmEAAQ==’,‘base64’) |
\x6f736462610001 |
encode(data bytea,type text) |
text |
Encode binary data into ASCII-only data, supported types include base64, hex, escape, etc. |
encode(E’osdba\000\001’,‘base64’) |
b3NkYmEAAQ== |
initcap(string) |
text |
The first letter of each word is converted to uppercase, and the other letters are converted to lowercase |
initcap(‘hi oSdBa’) |
Hi Osdba |
length(string) |
int |
number of characters in string |
length(‘osdba’) |
5 |
lpad(string text,length int [,fill text]) |
text |
By filling the character fill (default is blank), the string is filled to length length, if the string is already longer than length, its tail is truncated |
lpad(‘ok’,5,‘12’) |
121ok |
ltrim(string text [,characters text]) |
text |
Delete the characters contained in the parameter characters from the beginning of the string until a character that is not in the characters is encountered, the parameter characters default blank space |
ltrim('213osdba213', '123') |
osdba213 |
md5(string) |
text |
Computes the MD5 hash of string and returns the result in hexadecimal |
md5(‘osdba’) |
bc4e68be5b31f23d8d56c7f4c3351fec |
pg_client_encoding() |
name |
Current client code name |
pg_client_encoding() |
UTF8 |
quote_ident(string) |
text |
Returns the given string suitable for quoting, as an identifier in an SQL statement string. Quotes are added only if necessary (for example, if the string contains non-identifier characters or will be case-folded). |
quote_ident(‘osdba a’) |
“osdba a” |
quote_literal(string) |
text |
Returns a form suitable for use as text in an SQL statement, with embedded quotes and backslashes properly doubled |
quote_literal(E’O’Reilly’) |
‘O’‘Reilly’ |
regexp_replace(string text,pattern text,replacement text[,flags text]) |
text |
Replace substring matching POSIX regular expression |
regexp_replace(‘os123dba’,‘.[1-9]+’,‘#’) |
o#dba |
repeat(string text,unmber int) |
text |
将string重复number次 |
repeat(‘osdba’,3) |
osdbaosdbaosdba |
replace(string text,from text,to text) |
text |
把字符串string中出现的所有子字符串from替换成子字符串to |
replace(‘123osdba45osdba78’,‘osdba’,‘-’) |
123-45-78 |
rpad(string text,length int[,fill text]) |
text |
使用填充字符fill(默认空白),把string填充到length长度,如果string已经比length长,则从尾部将其截断 |
rpad(‘os’,6,‘123’) |
os1231 |
rtrim(string text[,characters text]) |
text |
从string末尾删除包含characters(默认空格)中仅包含字符的最长字符串 |
rtrim(‘trimxxxx’,‘x’) |
trim |
split_part(string text,delimiter text,field int) |
text |
根据delimiter分隔string返回生成的第field个子字符串(1为基) |
split_part(‘123#456#789’,‘#’,2) |
456 |
strpos(string,substring) |
int |
指定子字符串的位置,和position(substring in string)一样,不过参数顺序相反 |
strpos(‘osdba’,‘db’) |
3 |
substr(string,from [,count]) |
text |
抽取子字符串,和substring(string from for count)一样 |
substr(‘osdba’,2,2) |
sd |
to_ascii(string text[,encoding text]) |
text |
把string从其他编码转为ASCII(仅支持LATIN1,LATIN2,LATIN9,WIN1250编码) |
to_ascii(‘Osdba’) |
Osdba |
to_hex(unmber int或bigint) |
text |
把number转换成十六进制表现形式 |
to_hex(2147483647) |
7fffffff |
translate(string text,from text,to text) |
text |
把string中包含的所有匹配from的字符转化为对应的在to中的字符 |
translate(‘12345’,‘14’,‘db’) |
d23b5 |