String and VARCHAR
String stores variable-length UTF-8 text. Use it for names, labels, messages and other character data. Use BLOB for arbitrary bytes and FixedString for a fixed byte length.
Syntax
String
VARCHAR
VARCHAR(n)
NVARCHAR
NVARCHAR(n)
CHARACTER VARYING
CHARACTER VARYING(n)Length limits
String and the declarations without a length have no declared character limit. VARCHAR(n) and its length-qualified aliases accept at most n Unicode characters, including embedded NUL characters.
The limit counts characters, not UTF-8 bytes. Overlong input raises STRING_TOO_LONG; it is not silently truncated. Invalid UTF-8 binary input raises a conversion error.
These rules apply to casts, inserts, updates, defaults and generated values. A top-level column accepts NULL unless declared NOT NULL.
Examples
Storing Unicode text
CREATE TABLE labels(id UInt32, name VARCHAR(5));
INSERT INTO labels VALUES (1, 'hello'), (2, 'café');SELECT id, name, length(name) AS characters
FROM labels
ORDER BY id
FORMAT csv;1,"hello",5
2,"café",4A six-character value cannot be stored in this name column.
Casting to a limited string
SELECT CAST('abc' AS VARCHAR(3)), CAST(42 AS String)
FORMAT csv;"abc","42"See string functions for length, case conversion, slicing and concatenation.