PostgreSQL String Functions

This page lists PostgreSQL string functions that help you to manipulate strings efficiently.

  1. ascii

    The PostgreSQL ascii() function returns the numeric code of the first character of the specified string.
  2. bit_length

    The PostgreSQL bit_length() function returns the number of bits in the given string.
  3. btrim

    The PostgreSQL btrim() function removes the longest string containing only characters specified by the argument from the start and end of the given string.
  4. char_length

    The PostgreSQL char_length() function returns the number of characters in a string.
  5. character_length

    The PostgreSQL character_length() function returns the number of characters in a string.
  6. chr

    The PostgreSQL chr() function returns the character represented by the given code.
  7. concat

    The PostgreSQL concat() function concatenates all arguments as a string and returns the result.
  8. concat_ws

    The PostgreSQL concat_ws() function concatenates the arguments as a string using a delimiter and return the result.
  9. format

    The PostgreSQL format() function returns a formatted string according to the specified format string and arguments.
  10. initcap

    The PostgreSQL initcap() function converts the first letter of each word in the gaven string to uppercase and the rest to lowercase.
  11. left

    The PostgreSQL left() function extracts the leftmost specified number of characters in the gaven string and returns them as a string.
  12. length

    The PostgreSQL length() function returns the length of the specified string, that is, the number of characters.
  13. lower

    The PostgreSQL lower() function converts the string to lowercase according to the locale rules of the database and returns it.
  14. ltrim

    The PostgreSQL ltrim() function removes the longest string containing only characters specified by the argument (one space by default) from the start of a string.
  15. md5

    The PostgreSQL md5() function computes the md5 hash of a specified string and returns the result in hexadecimal form.
  16. normalize

    The PostgreSQL normalize() converts the given string to the specified Unicode normalized form and retruns the result.
  17. octet_length

    The PostgreSQL octet_length() function returns the length of a given string in bytes.
  18. overlay

    The PostgreSQL overlay() function replaces the specified number of characters starting at the specified position with the specified text in a string.
  19. parse_ident

    The PostgreSQL parse_ident() function splits the argument into an array of identifiers, and quotes around individual identifiers will be removed if possible.
  20. pg_client_encoding

    The PostgreSQL pg_client_encoding() function returns the encoding used by the client.
  21. position

    The PostgreSQL position() function returns the starting index of a specified substring within a specified string.
  22. quote_ident

    The PostgreSQL quote_ident() function returns the given string appropriately quoted for using as an identifier in SQL statement strings.
  23. quote_literal

    The PostgreSQL quote_literal() function uses single quotes to quote a given string for using as a string literal in SQL statement strings.
  24. quote_nullable

    The PostgreSQL quote_nullable() function uses single quotes to quote a given string for using as a string literal in SQL statement strings.
  25. regexp_match

    The PostgreSQL regexp_match() function returns the first match of the specified regular expression from a string.
  26. regexp_matches

    The PostgreSQL regexp_matches() function returns the result of the first match of the specified regular expression from a string; if the g flag used, all matches are returned.
  27. regexp_replace

    The PostgreSQL regexp_replace() function replaces the first matched substring of the given regular expression with the given replacement in a given string; if the g flag used, replaces all matches.
  28. regexp_split_to_array

    The PostgreSQL regexp_split_to_array() function splits a specified string into an array using a POSIX regular expression as the separator and returns the array.
  29. regexp_split_to_table

    The PostgreSQL regexp_split_to_table() function splits a specified string into a result set using the specified POSIX regular expression as the separator and returns the result set.
  30. repeat

    The PostgreSQL repeat() function repeats the specified string the specified number of times and returns the reuslt.
  31. replace

    The PostgreSQL replace() function replaces all occurrences of a specified substring in a specified string with a new text and returns the result.
  32. reverse

    The PostgreSQL reverse() function reverses the order of characters in a specified string and return the reversed string.
  33. right

    The PostgreSQL right() function extracts the rightmost specified number of characters in the specified string and returns returns them as a string.
  34. rpad

    The PostgreSQL rpad() function right pads the specified string with the specified characters to the specified length.
  35. rtrim

    The PostgreSQL rtrim() function removes the longest string containing only characters specified by the argument (whitespace by default) from end of a string.
  36. split_part

    The PostgreSQL split_part() function splits a specified string using the specified delimiter and returns the specified part.
  37. starts_with

    The PostgreSQL starts_with() function checks whether a string begins with a specified prefix.
  38. string_to_array

    The PostgreSQL string_to_array() function splits a specified string into an array according to the specified delimiter and returns the array.
  39. string_to_table

    The PostgreSQL string_to_table() function splits a specified string with the specified delimiter and returns the result as a set.
  40. strpos

    The PostgreSQL strpos() function returns the first starting index of a specified substring within a string.
  41. substr

    The PostgreSQL substr() function extracts and returns a substring from a specified string according to the specified starting position and length.
  42. substring

    The PostgreSQL substring() function extracts a substring from a specified string according to a specified starting position and length, or extract a substring according to regular expressions.
  43. to_ascii

    The PostgreSQL to_ascii() function converts the specified string from a specified encoding to ASCII.
  44. to_char

    The PostgreSQL to_char() function converts timestamp values, interval values, or numeric values ​​to strings according to the specified format and return the result.
  45. to_hex

    The PostgreSQL to_hex() function converts the specified number to a hexadecimal representation and returns the result.
  46. to_number

    The PostgreSQL to_number() function converts the specified string to a number according to the given format.
  47. translate

    The PostgreSQL translate() function translates a specified string according to the specified translation relation. A translation relationship is a one-to-one correspondence between characters in two strings.
  48. trim

    The PostgreSQL trim() function removes the longest string of specified characters from the start or/and end of the specified string.
  49. unistr

    The PostgreSQL unistr() function converts escaped Unicode characters to normal strings.
  50. upper

    The PostgreSQL upper() function converts the string to uppercase and returns it according to the locale rules of the database.