函数:chr(int)说明:Characterwiththegivencode.ForUTF8theargumentistreatedasaUnicodecodepoint.ForothermultibyteencodingstheargumentmustdesignateastrictlyASCIIcharacter.TheNULL(0)characterisnotallowedbecausetextdatatypescannotstoresuchbytes.得到某ACSII值对应的字符例子:chr(65)=A
函数:convert(stringbytea,src_encodingname,dest_encodingname)说明:Convertstringtodest_encoding.Theoriginalencodingisspecifiedbysrc_encoding.Thestringmustbevalidinthisencoding.ConversionscanbedefinedbyCREATECONVERSION.Alsotherearesomepredefinedconversions.SeeTable9-7foravailableconversions.转换字符串编码,指定源编码与目标编码例子:convert('text_in_utf8','UTF8','LATIN1')=text_in_utf8representedinISO8859-1encoding
函数:convert_from(stringbytea,src_encodingname)说明:Convertstringtothedatabaseencoding.Theoriginalencodingisspecifiedbysrc_encoding.Thestringmustbevalidinthisencoding.转换字符串编码,自己要指定源编码,目标编码默认为数据库指定编码,例子:convert_from('text_in_utf8','UTF8')=text_in_utf8representedinthecurrentdatabaseencoding
函数:convert_to(stringtext,dest_encodingname)说明:Convertstringtodest_encoding.转换字符串编码,源编码默认为数据库指定编码,自己要指定目标编码,例子:convert_to('sometext','UTF8')=sometextrepresentedintheUTF8encoding
函数:decode(stringtext,typetext)说明:Decodebinarydatafromstringpreviouslyencodedwithencode.Parametertypeissameasinencode.对字符串按指定的类型进行解码例子:decode('MTIzAAE=','base64')=123\000\001
函数:encode(databytea,typetext)说明:Encodebinarydatatodifferentrepresentation.Supportedtypesare:base64,hex,escape.Escapemerelyoutputsnullbytesas\000anddoublesbackslashes.与decode相反,对字符串按指定类型进行编码例子:encode(E'123\\000\\001','base64')=MTIzAAE=
函数:initcap(string)说明:Convertthefirstletterofeachwordtouppercaseandtheresttolowercase.Wordsaresequencesofalphanumericcharactersseparatedbynon-alphanumericcharacters.将字符串所有的单词进行格式化,首字母大写,其它为小写例子:initcap('hiTHOMAS')=HiThomas
函数:length(string)说明:Numberofcharactersinstring讲算字符串长度例子:length('jose')=4
函数:length(stringbytea,encodingname)说明:Numberofcharactersinstringinthegivenencoding.Thestringmustbevalidinthisencoding.计算字符串长度,指定字符串使用的编码例子:length('jose','UTF8')=4
*函数:lpad(stringtext,lengthint[,filltext])说明:Fillupthestringtolengthlengthbyprependingthecharactersfill(aspacebydefault).Ifthestringisalreadylongerthanlengththenitistruncated(ontheright).对字符串左边进行某类字符自动填充,即不足某一长度,则在左边自动补上指定的字符串,直至达到指定长度,可同时指定多个自动填充的字符例子:lpad('hi',5,'xy')=xyxhi
函数:ltrim(stringtext[,characterstext])说明:Removethelongeststringcontainingonlycharactersfromcharacters(aspacebydefault)fromthestartofstring删除字符串左边某一些的字符,可以时指定多个要删除的字符例子:trim
函数:md5(string)说明:CalculatestheMD5hashofstring,returningtheresultinhexadecimal将字符串进行md5编码例子:md5('abc')=900150983cd24fb0d6963f7d28e17f72
*函数:pg_client_encoding()说明:Currentclientencodingname得到pg客户端编码例子:pg_client_encoding()=SQL_ASCII
*函数:quote_ident(stringtext)说明:ReturnthegivenstringsuitablyquotedtobeusedasanidentifierinanSQLstatementstring.Quotesareaddedonlyifnecessary(i.e.,ifthestringcontainsnon-identifiercharactersorwouldbecase-folded).Embeddedquotesareproperlydoubled.对某一字符串加上两引号例子:quote_ident('Foobar')="Foobar"
*函数:quote_literal(stringtext)说明:ReturnthegivenstringsuitablyquotedtobeusedasastringliteralinanSQLstatementstring.Embeddedsingle-quotesandbackslashesareproperlydoubled.对字符串里两边加上单引号,如果字符串里面出现sql编码的单个单引号,则会被表达成两个单引号例子:quote_literal('O\'Reilly')='O''Reilly'

函数:regexp_matches(stringtext,patterntext[,flagstext])说明:ReturnallcapturedsubstringsresultingfrommatchingaPOSIXregularexpressionagainstthestring.SeeSection9.7.3formoreinformation.对字符串按正则表达式进行匹配,如果存在则会在结果数组中表示出来例子:regexp_matches('foobarbequebaz','(bar)(beque)')={bar,beque}
函数:regexp_replace(stringtext,patterntext,replacementtext[,flagstext])说明:Replacesubstring(s)matchingaPOSIXregularexpression.SeeSection9.7.3formoreinformation.利用正则表达式对字符串进行替换例子:regexp_replace('Thomas','.[mN]a.','M')=ThM
*函数:regexp_split_to_array(stringtext,patterntext[,flagstext])说明:SplitstringusingaPOSIXregularexpressionasthedelimiter.SeeSection9.7.3formoreinformation.利用正则表达式将字符串分割成数组例子:regexp_split_to_array('helloworld',E'\\s+')={hello,world}
*函数:regexp_split_to_table(stringtext,patterntext[,flagstext])说明:SplitstringusingaPOSIXregularexpressionasthedelimiter.SeeSection9.7.3formoreinformation.利用正则表达式将字符串分割成表格例子:regexp_split_to_table('helloworld',E'\\s+')=helloworld(2rows)
*函数:repeat(stringtext,numberint)说明:Repeatstringthespecifiednumberoftimes重复字符串一指定次数例子:repeat('Pg',4)=PgPgPgPg
函数:replace(stringtext,fromtext,totext)说明:Replacealloccurrencesinstringofsubstringfromwithsubstringto将字符的某一子串替换成另一子串例子:('abcdefabcdef','cd','XX')=abXXefabXXef
selectoverlay('http://tp2.sinaimg.cn/1928431341/50/5621497131/1'placing'/180/'fromposition('/50/'in'http://tp2.sinaimg.cn/1928431341/50/5621497131/1')for4),replace('http://tp2.sinaimg.cn/1928431341/50/5621497131/1','/50/','/180/');
*函数:rpad(stringtext,lengthint[,filltext])说明:Fillupthestringtolengthlengthbyappendingthecharactersfill(aspacebydefault).Ifthestringisalreadylongerthanlengththenitistruncated.对字符串进行填充,填充内容为指定的字符串例子:rpad('hi',5,'xy')=hixyx
函数:rtrim(stringtext[,characterstext])说明:Removethelongeststringcontainingonlycharactersfromcharacters(aspacebydefault)fromtheendofstring去除字符串右边指定的字符例子:rtrim('trimxxxx','x')=trim
*函数:split_part(stringtext,delimitertext,fieldint)说明:Splitstringondelimiterandreturnthegivenfield(countingfromone)?对字符串按指定子串进行分割,并返回指定的数值位置的值例子:split_part('abc~@~def~@~ghi','~@~',2)=def
函数:strpos(string,substring)说明:Locationofspecifiedsubstring(sameasposition(substringinstring),butnotethereversedargumentorder)指定字符串在目标字符串的位置例子:strpos('high','ig')=2
selectstrpos('http://tp2.sinaimg.cn/1928431341/50/5621497131/1','/50/'),position('/50/'in'http://tp2.sinaimg.cn/1928431341/50/5621497131/1');
函数:substr(string,from[,count])说明:Extractsubstring(sameassubstring(stringfromfromforcount))截取子串例子:substr('alphabet',3,2)=ph
*函数:to_ascii(stringtext[,encodingtext])说明:ConvertstringtoASCIIfromanotherencoding(onlysupportsconversionfromLATIN1,LATIN2,LATIN9,andWIN1250encodings)将字符串转换成ascii编码字符串例子:to_ascii('Karel')=Karel
*函数:to_hex(numberintorbigint)说明:Convertnumbertoitsequivalenthexadecimalrepresentation 对数值进行十六进制编码例子:to_hex(2147483647)=7fffffff
*函数:translate(stringtext,fromtext,totext)说明:Anycharacterinstringthatmatchesacharacterinthefromsetisreplacedbythecorrespondingcharacterinthetoset将字符串中某些匹配的字符替换成指定字符串,目标字符与源字符都可以同时指定多个例子:translate('12345','14','ax')=a23x5
本文来源:国外服务器--函数postgres二(post函数的用法)
本文地址:https://www.idcbaba.com/guowai/2580.html
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 1919100645@qq.com 举报,一经查实,本站将立刻删除。



