PostgreSQL: char_length Function
This PostgreSQL tutorial explains how to use the PostgreSQL char_length function with syntax and examples.
Description
The PostgreSQL char_length function returns the length of the specified string.
Syntax
The syntax for the char_length function in PostgreSQL is:
char_length( string )
Parameters or Arguments
- string
- The string to return the length for.
Note
- See also the character_length and length functions.
Applies To
The char_length function can be used in the following versions of PostgreSQL:
- PostgreSQL 9.4, PostgreSQL 9.3, PostgreSQL 9.2, PostgreSQL 9.1, PostgreSQL 9.0, PostgreSQL 8.4
Example
Let's look at some PostgreSQL char_length function examples and explore how to use the char_length function in PostgreSQL.
For example:
postgres=# SELECT char_length('Tech on the Net'); char_length ------------- 15 (1 row) postgres=# SELECT char_length('techonthenet.com'); char_length ------------- 16 (1 row) postgres=# SELECT char_length(''); char_length ------------- 0 (1 row) postgres=# SELECT char_length(' '); char_length ------------- 1 (1 row) postgres=# SELECT char_length(NULL); char_length ------------- <NULL> (1 row)
Advertisements