openGauss SQL参考—函数和操作符:二进制字符串函数和操作符(2)

二进制字符串函数

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

  • btrim(string bytea,bytes bytea)

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

    返回值类型:bytea

    示例:

    openGauss=# SELECT btrim(E'\\000trim\\000'::bytea, E'\\000'::bytea) AS RESULT;
       result   
    ------------
     \x7472696d
    (1 row)
    
  • get_bit(string, offset)

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

    返回值类型:int

    示例:

    openGauss=# SELECT get_bit(E'Th\\000omas'::bytea, 45) AS RESULT; 
     result
    --------
          1
    (1 row)
    
  • get_byte(string, offset)

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

    返回值类型:int

    示例:

    openGauss=# SELECT get_byte(E'Th\\000omas'::bytea, 4) AS RESULT; 
     result
    --------
        109
    (1 row)
    
  • set_bit(string,offset, newvalue)

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

    返回值类型:bytea

    示例:

    openGauss=# SELECT set_bit(E'Th\\000omas'::bytea, 45, 0) AS RESULT; 
          result      
    ------------------
     \x5468006f6d4173
    (1 row)
    
  • set_byte(string,offset, newvalue)

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

    返回值类型:bytea

    示例:

    openGauss=# SELECT set_byte(E'Th\\000omas'::bytea, 4, 64) AS RESULT; 
          result      
    ------------------
     \x5468006f406173
    (1 row)
posted @ 2024-07-30 10:39  openGauss-bot  阅读(12)  评论(0)    收藏  举报