Home Explore Blog CI



postgresql

35th chunk of `doc/src/sgml/func.sgml`
308452a6aa7b56188bed716a389925afe7a97a4aa803dcba0000000100000fa5
 role="func_table_entry"><para role="func_signature">
        <indexterm>
         <primary>concat</primary>
        </indexterm>
        <function>concat</function> ( <parameter>val1</parameter> <type>"any"</type>
         <optional>, <parameter>val2</parameter> <type>"any"</type> <optional>, ...</optional> </optional> )
        <returnvalue>text</returnvalue>
       </para>
       <para>
        Concatenates the text representations of all the arguments.
        NULL arguments are ignored.
       </para>
       <para>
        <literal>concat('abcde', 2, NULL, 22)</literal>
        <returnvalue>abcde222</returnvalue>
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <indexterm>
         <primary>concat_ws</primary>
        </indexterm>
        <function>concat_ws</function> ( <parameter>sep</parameter> <type>text</type>,
        <parameter>val1</parameter> <type>"any"</type>
        <optional>, <parameter>val2</parameter> <type>"any"</type> <optional>, ...</optional> </optional> )
        <returnvalue>text</returnvalue>
       </para>
       <para>
        Concatenates all but the first argument, with separators. The first
        argument is used as the separator string, and should not be NULL.
        Other NULL arguments are ignored.
       </para>
       <para>
        <literal>concat_ws(',', 'abcde', 2, NULL, 22)</literal>
        <returnvalue>abcde,2,22</returnvalue>
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <indexterm>
         <primary>format</primary>
        </indexterm>
        <function>format</function> ( <parameter>formatstr</parameter> <type>text</type>
        <optional>, <parameter>formatarg</parameter> <type>"any"</type> <optional>, ...</optional> </optional> )
        <returnvalue>text</returnvalue>
       </para>
       <para>
         Formats arguments according to a format string;
         see <xref linkend="functions-string-format"/>.
         This function is similar to the C function <function>sprintf</function>.
       </para>
       <para>
        <literal>format('Hello %s, %1$s', 'World')</literal>
        <returnvalue>Hello World, World</returnvalue>
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <indexterm>
         <primary>initcap</primary>
        </indexterm>
        <function>initcap</function> ( <type>text</type> )
        <returnvalue>text</returnvalue>
       </para>
       <para>
        Converts the first letter of each word to upper case and the
        rest to lower case. Words are sequences of alphanumeric
        characters separated by non-alphanumeric characters.
       </para>
       <para>
        <literal>initcap('hi THOMAS')</literal>
        <returnvalue>Hi Thomas</returnvalue>
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <indexterm>
         <primary>casefold</primary>
        </indexterm>
        <function>casefold</function> ( <type>text</type> )
        <returnvalue>text</returnvalue>
       </para>
       <para>
        Performs case folding of the input string according to the collation.
        Case folding is similar to case conversion, but the purpose of case
        folding is to facilitate case-insensitive matching of strings,
        whereas the purpose of case conversion is to convert to a particular
        cased form.  This function can only be used when the server encoding
        is <literal>UTF8</literal>.
       </para>
       <para>
        Ordinarily, case folding simply converts to lowercase, but there may
        be exceptions depending on the collation.  For instance, some
        characters have more than two lowercase variants, or fold to uppercase.
       </para>
       <para>
        Case folding may change the length of the string.  For instance,

Title: PostgreSQL String Functions: CONCAT_WS, FORMAT, INITCAP, and CASEFOLD
Summary
This section describes additional PostgreSQL string functions: `concat_ws` (concatenates arguments with a separator), `format` (formats arguments according to a format string), `initcap` (capitalizes the first letter of each word), and `casefold` (performs case folding for case-insensitive string matching in UTF8 encoding).