二进制字符串函数和操作符

    • octet_length(string)

      描述:二进制字符串中的字节数。

      返回值类型:int

      示例:

    • overlay(string placing string from int [for int])

      描述:替换子串。

      返回值类型:bytea

      示例:

      1. result
      2. ----------------
      3. \x5402036d6173
      4. (1 row)
    • position(substring in string)

      描述:特定子字符串的位置。

      返回值类型:int

      示例:

      1. postgres=# SELECT position(E'\\000om'::bytea in E'Th\\000omas'::bytea) AS RESULT;
      2. result
      3. --------
      4. (1 row)
    • substring(string [from int] [for int])

      返回值类型:bytea

      示例:

    • trim([both] bytes from string)

      描述:从string的开头和结尾删除只包含bytes中字节的最长字符串。

      返回值类型:bytea

      示例:

      1. result
      2. ----------
      3. \x546f6d
      4. (1 row)

    二进制字符串函数

    openGauss也提供了函数调用所使用的常用语法。

    • btrim(string bytea,bytes bytea)

      描述:从string的开头和结尾删除只包含bytes中字节的最长的字符串。

      返回值类型:bytea

      示例:

      1. postgres=# SELECT btrim(E'\\000trim\\000'::bytea, E'\\000'::bytea) AS RESULT;
      2. result
      3. ------------
      4. \x7472696d
    • get_bit(string, offset)

      描述:从字符串中抽取位。

      示例:

    • get_byte(string, offset)

      描述:从字符串中抽取字节。

      返回值类型:int

      示例:

      1. result
      2. --------
      3. 109
      4. (1 row)
    • set_bit(string,offset, newvalue)

      描述:设置字符串中的位。

      返回值类型:bytea

      示例:

      1. postgres=# SELECT set_bit(E'Th\\000omas'::bytea, 45, 0) AS RESULT;
      2. result
      3. ------------------
      4. \x5468006f6d4173
      5. (1 row)