null
char varying
synonymThe variable-length character string type of SQL is character varying
but the shorter synonyms char varying
and most importantly varchar
are more commonly used.
CREATE TABLE … (
email VARCHAR(320)
)
The varchar
type can be parameterized to set a maximum length, like 320 in the example. Note that the unit are characters, not bytes.✓✗ In absence of the length attribute, the maximum length is implementation-defined (ID069), which is sometimes just a single character.
As the type varchar
stores characters, rather than bytes, the character set
and collate
clauses may be specified.
The SQL types character varying
, char varying
and char
are defined in ISO/IEC 9075-2:2023 as mandatory feature E021-02, “CHARACTER VARYING data type (including all its spellings)”. They were already available in SQL-92 (entry level).
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.
The essence of SQL tuning in 200 pages
Buy now!
(paperback and/or PDF)
Paperback also available at Amazon.com.
Markus offers SQL training and consulting for developers working at companies of all sizes.
Learn more »