NORMALIZE
NORMALIZE is a SQL function used to transform a string into a standardized form, optimized for comparison and searching. The transformation process follows the Unicode normalization method. This function is an essential tool in data processing and analytics, helping ensure database uniformity.
Example
SELECT NORMALIZE('Ábc');
Output
'Abc'
Explanation
The NORMALIZE()
function is used to transform a text string into a form that can be compared on an equivalent basis. In the provided example, the NORMALIZE function transforms the ‘Á’ character into ‘A’.
Example
CREATE EXTENSION IF NOT EXISTS isn;CREATE TABLE test (col VARCHAR(10));INSERT INTO test VALUES ('1234'), ('5678'), ('9123');SELECT col, NORMALIZE(col) as normalized_col FROM test;
Output
col | normalized_col------+---------------1234 | 12345678 | 56789123 | 9123
Explanation
The NORMALIZE function in PostgreSQL transforms a string into its normalized form, which means it rearranges accented characters and similar entities into a standard form. In this example, the values in col
are already normalized, hence the normalized output is equivalent to the input.