mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Add string functions: concat(), concat_ws(), left(), right(), and reverse().
Pavel Stehule, reviewed by me.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.529 2010/08/17 04:37:20 petere Exp $ -->
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.530 2010/08/24 06:30:43 itagaki Exp $ -->
|
||||
|
||||
<chapter id="functions">
|
||||
<title>Functions and Operators</title>
|
||||
@ -1250,6 +1250,12 @@
|
||||
<indexterm>
|
||||
<primary>chr</primary>
|
||||
</indexterm>
|
||||
<indexterm>
|
||||
<primary>concat</primary>
|
||||
</indexterm>
|
||||
<indexterm>
|
||||
<primary>concat_ws</primary>
|
||||
</indexterm>
|
||||
<indexterm>
|
||||
<primary>convert</primary>
|
||||
</indexterm>
|
||||
@ -1268,6 +1274,9 @@
|
||||
<indexterm>
|
||||
<primary>initcap</primary>
|
||||
</indexterm>
|
||||
<indexterm>
|
||||
<primary>left</primary>
|
||||
</indexterm>
|
||||
<indexterm>
|
||||
<primary>lpad</primary>
|
||||
</indexterm>
|
||||
@ -1295,6 +1304,12 @@
|
||||
<indexterm>
|
||||
<primary>replace</primary>
|
||||
</indexterm>
|
||||
<indexterm>
|
||||
<primary>reverse</primary>
|
||||
</indexterm>
|
||||
<indexterm>
|
||||
<primary>right</primary>
|
||||
</indexterm>
|
||||
<indexterm>
|
||||
<primary>rpad</primary>
|
||||
</indexterm>
|
||||
@ -1374,6 +1389,34 @@
|
||||
<entry><literal>A</literal></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>
|
||||
<literal><function>concat</function>(<parameter>str</parameter> <type>"any"</type>
|
||||
[, <parameter>str</parameter> <type>"any"</type> [, ...] ])</literal>
|
||||
</entry>
|
||||
<entry><type>text</type></entry>
|
||||
<entry>
|
||||
Concatenate all arguments. NULL arguments are ignored.
|
||||
</entry>
|
||||
<entry><literal>concat('abcde', 2, NULL, 22)</literal></entry>
|
||||
<entry><literal>abcde222</literal></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>
|
||||
<literal><function>concat_ws</function>(<parameter>sep</parameter> <type>text</type>,
|
||||
<parameter>str</parameter> <type>"any"</type>
|
||||
[, <parameter>str</parameter> <type>"any"</type> [, ...] ])</literal>
|
||||
</entry>
|
||||
<entry><type>text</type></entry>
|
||||
<entry>
|
||||
Concatenate all but first arguments with separators. The first
|
||||
parameter is used as a separator. NULL arguments are ignored.
|
||||
</entry>
|
||||
<entry><literal>concat_ws(',', 'abcde', 2, NULL, 22)</literal></entry>
|
||||
<entry><literal>abcde,2,22</literal></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>
|
||||
<literal><function>convert</function>(<parameter>string</parameter> <type>bytea</type>,
|
||||
@ -1465,6 +1508,20 @@
|
||||
<entry><literal>Hi Thomas</literal></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>
|
||||
<literal><function>left</function>(<parameter>str</parameter> <type>text</type>,
|
||||
<parameter>n</parameter> <type>int</type>)</literal>
|
||||
</entry>
|
||||
<entry><type>text</type></entry>
|
||||
<entry>
|
||||
Return first <replaceable>n</> characters in the string. When <replaceable>n</>
|
||||
is negative, return all but last |<replaceable>n</>| characters.
|
||||
</entry>
|
||||
<entry><literal>left('abcde', 2)</literal></entry>
|
||||
<entry><literal>ab</literal></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><literal><function>length</function>(<parameter>string</parameter>)</literal></entry>
|
||||
<entry><type>int</type></entry>
|
||||
@ -1678,6 +1735,32 @@
|
||||
<entry><literal>abXXefabXXef</literal></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>
|
||||
<literal><function>reverse</function>(<parameter>str</parameter>)</literal>
|
||||
</entry>
|
||||
<entry><type>text</type></entry>
|
||||
<entry>
|
||||
Return reversed string.
|
||||
</entry>
|
||||
<entry><literal>reverse('abcde')</literal></entry>
|
||||
<entry><literal>edcba</literal></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>
|
||||
<literal><function>right</function>(<parameter>str</parameter> <type>text</type>,
|
||||
<parameter>n</parameter> <type>int</type>)</literal>
|
||||
</entry>
|
||||
<entry><type>text</type></entry>
|
||||
<entry>
|
||||
Return last <replaceable>n</> characters in the string. When <replaceable>n</>
|
||||
is negative, return all but first |<replaceable>n</>| characters.
|
||||
</entry>
|
||||
<entry><literal>right('abcde', 2)</literal></entry>
|
||||
<entry><literal>de</literal></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>
|
||||
<literal><function>rpad</function>(<parameter>string</parameter> <type>text</type>,
|
||||
|
Reference in New Issue
Block a user