當前位置:網站首頁>GBase 8c 字符串操作符

GBase 8c 字符串操作符

2022-07-24 00:16:18大壯十二

GBase 8c 數據庫提供一些字符串操作符,在這些函數裏使用關鍵字而不是逗號來分隔參數。

  1. octet_length(string)

描述:二進制字符串中的字節數。返回值類型:int

示例:

gbase=# SELECT octet_length(E'jo\\000se'::bytea) AS RESULT;

result

--------

      5

(1 row)

  1. overlay(string placing string from int [for int])

描述:替換子串。返回值類型:bytea

示例:

gbase=# SELECT overlay(E'Th\\000omas'::bytea placing E'\\002\\003'::bytea from 2 for 3) AS RESULT;

result

----------------

\x5402036d6173

(1 row)

  1. position(substring in string) 描述:特定子字符串的比特置。返回值類型:int

示例:

gbase=# SELECT position(E'\\000om'::bytea in E'Th\\000omas'::bytea) AS RESULT;

result

--------

3

(1 row)

  1. substring(string [from int] [for int])

描述:截取子串。返回值類型:bytea

示例:

gbase=# SELECT substring(E'Th\\000omas'::bytea from 2 for 3) AS RESULT;

 result

----------

\x68006f

(1 row)

  1. substr(string, from int [, for int])

描述:截取子串。返回值類型:bytea

示例:

gbase=# select substr(E'Th\\000omas'::bytea,2, 3) as result;

result

----------

\x68006f

(1 row)

  1. trim([both] bytes from string)

描述:從string的開頭和結尾删除只包含bytes中字節的最長字符串。返回值類型:bytea

示例:

gbase=# SELECT trim(E'\\000'::bytea from E'\\000Tom\\000'::bytea) AS RESULT;

result

----------

\x546f6d

(1 row)

版權聲明
本文為[大壯十二]所創,轉載請帶上原文鏈接,感謝
https://cht.chowdera.com/2022/205/202207240015540212.html

隨機推薦