![]() ![]() In this tutorial, you have learned how to use the PostgreSQL TRANSLATE() function to substitute characters in a set with another, one-to-one, in a single operation. PostgreSQL CONCAT () function Last update on Aug21:50:44 (UTC/GMT +8 hours) CONCAT () function The PostgreSQL concat () function is used to concatenate two or more strings except NULL specified in the arguments. 'abcdefghijklmnopqrstuvxyz') Code language: JavaScript ( javascript ) You can also decrypt the message '0 o42i4p w4oo064' using the function: SELECT TRANSLATE( '0 o42i4p w4oo064', ![]() '0123456789acwrvyuiopkjhbq') Code language: JavaScript ( javascript ) The following example shows how to use the TRANSLATE() function to encrypt a message: SELECT TRANSLATE( 'a secret message', SELECT TRANSLATE( 'apple,orange,banana', ',', ' ') Code language: JavaScript ( javascript ) The following example shows how to use the TRANSLATE() function to replace comma (,) by a semi-colon ( ) in a comma-separated values list. ![]() The following illustrates the result: translate Since version 9. Because the string '134' has more characters than the string 'ax', the TRANSLATE() function removes the extra character in the string '134', which is '4', from the string '12345'. To concatenate two or more strings into one, you use the string concatenation operator as the following example: The following statement concatenates a string with a NULLvalue: It returns a NULLvalue.The character '1' in string '12345' is substituted by character 'a', The character '3' in the string '12345' is substituted by the character 'x'.By the way, WS stands for with separator. See the following statement: SELECT TRANSLATE( '12345', '134', 'ax') Code language: JavaScript ( javascript ) Besides the CONCAT function, PostgreSQL also provides you with the CONCATWS function that concatenates strings into one separated by a particular separator. Letâs see some examples of using the TRANSLATE() function to understand how it works. The PostgreSQL TRANSLATE() function returns a string with the characters in the one set of characters are replaced by another set of characters. Notice that if from is longer than to, the TRANSLATE() function removes the occurrences of the extra characters in from. Is a set of characters that replaces the from in the string. Is a set of characters in the first argument ( string) that should be replaced. The PostgreSQL TRANSLATE() function accepts three arguments: The following illustrates the syntax of the PostgreSQL TRANSLATE() function: TRANSLATE(string, from, to) Code language: JavaScript ( javascript ) Arguments The PostgreSQL TRANSLATE() function performs several single-character, one-to-one translation in one operation. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |