関数 | 返り値型 | 説明 | 例 |
string || string | text | 文字列結合 | 'Post' || 'greSQL' |
bit_length(string) | integer | 文字列のビット数 | bit_length('jose') |
char_length(string) or character_length(string) | integer | 文字列の中の文字数 | char_length('jose') |
lower(string) | text (テキスト) | 文字列を小文字に変換 | lower('TOM') |
octet_length(string) | integer | 文字列のバイト数 | octet_length('jose') |
overlay(string placing string from integer [for integer]) | text (テキスト) | 部分文字列の挿入 | overlay('Txxxxas' placing 'hom' from 2 for 4) |
position(substring in string) | integer | 指定された部分文字列の場所 | position('om' in 'Thomas') |
substring(string [from integer] [for integer]) | text (テキスト) | 部分文字列の取り出し | substring('Thomas' from 2 for 3) |
substring(string from pattern) | text (テキスト) | POSIX 正規表現にマッチする部分文字列の取り出し | substring('Thomas' from '...$') |
substring(string from pattern for escape) | text (テキスト) | SQL 正規表現にマッチする部分文字列の取り出し | substring('Thomas' from '%#"o_a#"_' for '#') |
trim([leading | trailing | both] [characters] from string) | text (テキスト) | characters (デフォルトではスペース) で指定された文字のみを含む最も長い文字列を、string の最初、最後、そして両側から削除します。 | trim(both 'x' from 'xTomxx') |
upper(string) | text (テキスト) | 文字列を大文字に変換 | upper('tom') |
initcap(text) | text (テキスト) | (空白で区切られた) それぞれの単語の第一文字を大文字にします。 | initcap('hi thomas') |
length(string) | integer | 文字列の長さ | length('jose') |
repeat(text, integer) | text (テキスト) | テキストを指定回数分繰り返します。 | repeat('Pg', 4) |
replace(string text, from text, to text) | text (テキスト) | string に出現するすべての from 部分文字列を to 部分文字列に置換します。 | replace('abcdefabcdef', 'cd', 'XX') |
split_part(string text, delimiter text, column integer) | text (テキスト) | string を delimiter で分割し、その結果から column 番目の文字列を返します。 | split_part('abc~@~def~@~ghi','~@~',2) |
substr(string, from [, count]) | text (テキスト) | 指定した部分文字列を取り出します (substring(string from from for count) と同じです)。 | substr('alphabet', 3, 2) |
to_hex(number integer or bigint) | text (テキスト) | number を、同等の 16 進数表現に変換します。 | to_hex(9223372036854775807::bigint) |
translate(string text, from text, to text) | text (テキスト) | from で指定された文字と一致する string にあるすべての文字は、それに対応する to で指定された文字に置き換えられます。 | translate('12345', '14', 'ax') |