The LENGTH() function

Informix®

Informix provides the LENGTH() function to count the number of bytes of a character string expression:

SELECT LENGTH("aaa"), LENGTH(col1) FROM table 

Informix LENGTH() does not count the trailing blanks for CHAR or VARCHAR expressions, while Oracle counts the trailing blanks.

Informix LENGTH() returns 0 when the given string is empty. That means, LENGTH('')=0.

PostgreSQL

PostgreSQL supports the LENGTH() function, which is similar to Informix LENGTH().

The PostgreSQL LENGTH() function ignores trailing blanks.

When passing NULL as parameter, the PostgreSQL LENGTH() function returns NULL.

Solution

The SQL LENGTH() function name can be used with PostgreSQL.