PostgreSQL String Functions
This page lists PostgreSQL string functions that help you to manipulate strings efficiently.
-
ascii
The PostgreSQLascii()
function returns the numeric code of the first character of the specified string. -
bit_length
The PostgreSQLbit_length()
function returns the number of bits in the given string. -
btrim
The PostgreSQLbtrim()
function removes the longest string containing only characters specified by the argument from the start and end of the given string. -
char_length
The PostgreSQLchar_length()
function returns the number of characters in a string. -
character_length
The PostgreSQLcharacter_length()
function returns the number of characters in a string. -
chr
The PostgreSQLchr()
function returns the character represented by the given code. -
concat
The PostgreSQLconcat()
function concatenates all arguments as a string and returns the result. -
concat_ws
The PostgreSQLconcat_ws()
function concatenates the arguments as a string using a delimiter and return the result. -
format
The PostgreSQLformat()
function returns a formatted string according to the specified format string and arguments. -
initcap
The PostgreSQLinitcap()
function converts the first letter of each word in the gaven string to uppercase and the rest to lowercase. -
left
The PostgreSQLleft()
function extracts the leftmost specified number of characters in the gaven string and returns them as a string. -
length
The PostgreSQLlength()
function returns the length of the specified string, that is, the number of characters. -
lower
The PostgreSQLlower()
function converts the string to lowercase according to the locale rules of the database and returns it. -
ltrim
The PostgreSQLltrim()
function removes the longest string containing only characters specified by the argument (one space by default) from the start of a string. -
md5
The PostgreSQLmd5()
function computes the md5 hash of a specified string and returns the result in hexadecimal form. -
normalize
The PostgreSQLnormalize()
converts the given string to the specified Unicode normalized form and retruns the result. -
octet_length
The PostgreSQLoctet_length()
function returns the length of a given string in bytes. -
overlay
The PostgreSQLoverlay()
function replaces the specified number of characters starting at the specified position with the specified text in a string. -
parse_ident
The PostgreSQLparse_ident()
function splits the argument into an array of identifiers, and quotes around individual identifiers will be removed if possible. -
pg_client_encoding
The PostgreSQLpg_client_encoding()
function returns the encoding used by the client. -
position
The PostgreSQLposition()
function returns the starting index of a specified substring within a specified string. -
quote_ident
The PostgreSQLquote_ident()
function returns the given string appropriately quoted for using as an identifier in SQL statement strings. -
quote_literal
The PostgreSQLquote_literal()
function uses single quotes to quote a given string for using as a string literal in SQL statement strings. -
quote_nullable
The PostgreSQLquote_nullable()
function uses single quotes to quote a given string for using as a string literal in SQL statement strings. -
regexp_match
The PostgreSQLregexp_match()
function returns the first match of the specified regular expression from a string. -
regexp_matches
The PostgreSQLregexp_matches()
function returns the result of the first match of the specified regular expression from a string; if theg
flag used, all matches are returned. -
regexp_replace
The PostgreSQLregexp_replace()
function replaces the first matched substring of the given regular expression with the given replacement in a given string; if theg
flag used, replaces all matches. -
regexp_split_to_array
The PostgreSQLregexp_split_to_array()
function splits a specified string into an array using a POSIX regular expression as the separator and returns the array. -
regexp_split_to_table
The PostgreSQLregexp_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. -
repeat
The PostgreSQLrepeat()
function repeats the specified string the specified number of times and returns the reuslt. -
replace
The PostgreSQLreplace()
function replaces all occurrences of a specified substring in a specified string with a new text and returns the result. -
reverse
The PostgreSQLreverse()
function reverses the order of characters in a specified string and return the reversed string. -
right
The PostgreSQLright()
function extracts the rightmost specified number of characters in the specified string and returns returns them as a string. -
rpad
The PostgreSQLrpad()
function right pads the specified string with the specified characters to the specified length. -
rtrim
The PostgreSQLrtrim()
function removes the longest string containing only characters specified by the argument (whitespace by default) from end of a string. -
split_part
The PostgreSQLsplit_part()
function splits a specified string using the specified delimiter and returns the specified part. -
starts_with
The PostgreSQLstarts_with()
function checks whether a string begins with a specified prefix. -
string_to_array
The PostgreSQLstring_to_array()
function splits a specified string into an array according to the specified delimiter and returns the array. -
string_to_table
The PostgreSQLstring_to_table()
function splits a specified string with the specified delimiter and returns the result as a set. -
strpos
The PostgreSQLstrpos()
function returns the first starting index of a specified substring within a string. -
substr
The PostgreSQLsubstr()
function extracts and returns a substring from a specified string according to the specified starting position and length. -
substring
The PostgreSQLsubstring()
function extracts a substring from a specified string according to a specified starting position and length, or extract a substring according to regular expressions. -
to_ascii
The PostgreSQLto_ascii()
function converts the specified string from a specified encoding to ASCII. -
to_char
The PostgreSQLto_char()
function converts timestamp values, interval values, or numeric values ββto strings according to the specified format and return the result. -
to_hex
The PostgreSQLto_hex()
function converts the specified number to a hexadecimal representation and returns the result. -
to_number
The PostgreSQLto_number()
function converts the specified string to a number according to the given format. -
translate
The PostgreSQLtranslate()
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. -
trim
The PostgreSQLtrim()
function removes the longest string of specified characters from the start or/and end of the specified string. -
unistr
The PostgreSQLunistr()
function converts escaped Unicode characters to normal strings. -
upper
The PostgreSQLupper()
function converts the string to uppercase and returns it according to the locale rules of the database.