SQLite 3 reference · String Functions

SQLite OCTET_LENGTH() Function

Return the number of bytes a string takes in the database encoding (usually UTF-8), not the number of characters.

SQLite 3 Since 3.43.0

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

octet_length(X)

Parameters

ParameterDescription
X The string (other values are converted to text).

Return value

An integer, or NULL.

Examples

Bytes per stringTry it yourself
SELECT octet_length('abc') AS ascii, octet_length('naïve') AS utf8;

Output

ascii | utf8
3 | 6
Next to length()Try it yourself
SELECT name, length(name) AS chars, octet_length(name) AS bytes
FROM customers
WHERE customer_id = 1;

Output

name | chars | bytes
Ada Lovelace | 12 | 12

Version history

VersionChange
SQLite 3.43.0Added

In other languages

Was this page helpful?