Skip to content

OCTET_LENGTH

Return the number of bytes in a character string.

OCTET_LENGTH(string)

For example:

premdb=# SELECT season_name, OCTET_LENGTH(season_name) FROM season;
 season_name | octet_length 
-------------+--------------
 1992-1993   |            9
 1993-1994   |            9
 1994-1995   |            9
 1995-1996   |            9
...
multibyte=# create table multibyte(c1 varchar(10));
CREATE TABLE
multibyte=# insert into multibyte values('谢谢');
INSERT 0 1
multibyte=# select length(c1), octet_length(c1) from multibyte;
 length | octet_length 
--------+--------------
     2 |            6
(1 row)

Parent topic:String Functions