T062, “Character length units”


BigQueryDb2 (LUW)DerbyH2MariaDBMySQLOracle DBPostgreSQLSQL ServerSQLite20092011201320152017201920212023⊘ 3.5.7 - 3.50.0⊘ 2008R2 - 2022⊘ 8.3 - 17⊘ 11gR1 - 23.9a⊘ 5.0 - 9.3.0⊘ 5.1 - 12.0.2⊘ 1.4.192 - 2.3.232⊘ 10.15.1.3 - 10.17.1.0⚠ 10.5 - 12.1.2bc⊘ 9.7a⊘ 2.0
  1. Non-standard alternatives available
  2. Only octets
  3. Not for national types

For character strings, SQL allows to declare whether the length means characters or octets, i.e. bytes.

CREATE TABLE … (
  c1 VARCHAR(10),
  c2 VARCHAR(10 CHARACTERS),
  c3 VARCHAR(10 OCTETS)
)

In absence of an explicit length unit, characters is default.✓✗0 The following chart shows that not all systems apply that default correctly. Note that the behavior might also depend on installation defaults, like the character encoding, so that your system might behave differently.

BigQuery 2025-09-02Db2 (LUW) 12.1.2aaDerby 10.17.1.0H2 2.3.232MariaDB 12.0.2MySQL 9.3.0Oracle DB 23.9bbbPostgreSQL 17SQL Server 2022deSQLite 3.50.0cccdefault length unit: charactersdefault length unit:     octetsdefault length unit: 16-bit code units
  1. Characters for national types, depends on nls_string_units for the other types
  2. 16 bit units for national types, depends on nls_length_semantics for the other types
  3. Length limitation not enforced
  4. When using UTF8
  5. Observed with the default character set

Non-Standard Alternatives

The standard defines the keywords characters and octets (both plural) for the length units. Yet some systems support different words only.

BigQuery 2025-09-02Db2 (LUW) 12.1.2aaDerby 10.17.1.0H2 2.3.232MariaDB 12.0.2MySQL 9.3.0Oracle DB 23.9aaaPostgreSQL 17SQL Server 2022SQLite 3.50.0bytecharcharactercodeunits32
  1. Not for national types
Mandatory Features
Optional Features
Implementation-defined Elements

Normative References

The <character length unit> was introduced with ISO/IEC 9075-2:2003 as part of the optional feature T061, “UCS support”. With the 2023 edition of the standard, it has got its own Feature ID: T062, “Character length units”.

You can’t catch up on 20 years of SQL evolution in one day. Subscribe the newsletter via E-Mail, Bluesky or RSS to gradually catch up and to keep modern-⁠sql.com on your radar.

About the Author

Photo of Markus Winand

Markus Winand provides insights into SQL and shows how different systems support it at modern-sql.com. Previously he made use-the-index-luke.com, which is still actively maintained. Markus can be hired as trainer, speaker and consultant via winand.at.

Buy the Book

Cover of “SQL Performance Explained”: Squirrel running on grass

The essence of SQL tuning in 200 pages

Buy now!
(paperback and/or PDF)

Paperback also available at Amazon.com.

Hire Markus

Markus offers SQL training and consulting for developers working at companies of all sizes.
Learn more »

Footnotes

  1. ISO/IEC 9075-2:2023 §6.1 SR 9

Connect with Markus Winand

Subscribe mailinglistsSubscribe the RSS feedMarkus Winand on LinkedInMarkus Winand on XINGMarkus Winand on TwitterMarkus Winand on Bluesky
Copyright 2015-2025 Markus Winand. All righs reserved.
Legal | Contact | NO WARRANTY | Trademarks | Privacy and GDPR