Expand description

String expressions

Functions§

  • Returns the numeric code of the first character of the argument. ascii(‘x’) = 120
  • Returns the longest string with leading and trailing characters removed. If the characters are not specified, whitespace is removed. btrim(‘xyxtrimyyx’, ‘xyz’) = ‘trim’
  • Returns the character with the given code. chr(0) is disallowed because text data types cannot store that character. chr(65) = ‘A’
  • Concatenates the text representations of all the arguments. NULL arguments are ignored. concat(‘abcde’, 2, NULL, 22) = ‘abcde222’
  • 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. concat_ws(‘,’, ‘abcde’, 2, NULL, 22) = ‘abcde,2,22’
  • 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. initcap(‘hi THOMAS’) = ‘Hi Thomas’
  • Returns the Levenshtein distance between the two given strings. LEVENSHTEIN(‘kitten’, ‘sitting’) = 3
  • Converts the string to all lower case. lower(‘TOM’) = ‘tom’
  • Returns the longest string with leading characters removed. If the characters are not specified, whitespace is removed. ltrim(‘zzzytest’, ‘xyz’) = ‘test’
  • OVERLAY(string1 PLACING string2 FROM integer FOR integer2) Replaces a substring of string1 with string2 starting at the integer bit pgsql overlay(‘Txxxxas’ placing ‘hom’ from 2 for 4) → Thomas overlay(‘Txxxxas’ placing ‘hom’ from 2) -> Thomxas, without for option, str2’s len is instead
  • Repeats string the specified number of times. repeat(‘Pg’, 4) = ‘PgPgPgPg’
  • Replaces all occurrences in string of substring from with substring to. replace(‘abcdefabcdef’, ‘cd’, ‘XX’) = ‘abXXefabXXef’
  • Returns the longest string with trailing characters removed. If the characters are not specified, whitespace is removed. rtrim(‘testxxzx’, ‘xyz’) = ‘test’
  • Splits string at occurrences of delimiter and returns the n’th field (counting from one). split_part(‘abc~@def@ghi’, ‘@~’, 2) = ‘def’
  • Returns true if string starts with prefix. starts_with(‘alphabet’, ‘alph’) = ‘t’
  • Converts the number to its equivalent hexadecimal representation. to_hex(2147483647) = ‘7fffffff’
  • Converts the string to all upper case. upper(‘tom’) = ‘TOM’
  • Prints random (v4) uuid values per row uuid() = ‘a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11’