VARCHARACTER (commonly written VARCHAR or CHARACTER VARYING) is the ANSI-standard variable-length character string type. Unlike CHAR, it stores only the actual characters supplied and does not right-pad with spaces. A maximum length must be supplied in parentheses; this length is measured in characters, not bytes, although some dialects enforce byte limits internally. When a value longer than the declared limit is inserted, the database either rejects the row, truncates the value, or raises a warning depending on the dialect and SQL mode. Indexing, collation, and case-sensitivity follow the database’s rules for string types. Storage overhead usually includes one or two bytes per row to record the string’s actual length. In most systems, VARCHARACTER and VARCHAR are synonyms; Oracle uses VARCHAR2, and SQL Server distinguishes between VARCHAR (single-byte) and NVARCHAR (Unicode).
n
(integer) - Maximum number of characters that can be stored (required, 1 to dialect-specific upper limit)encoding
(implicit) - Character set follows the table or column collation/charset settingsSQL-92
Maximum length is dialect-specific: 65,535 in MySQL, 1 GB in PostgreSQL, 8,000 for SQL Server VARCHAR (2 GB for VARCHAR(MAX)).
No. It stores only the actual characters plus a small length prefix, unlike CHAR which always uses the fixed size.
Most databases store Unicode directly when the column or database uses a UTF charset. Length is still counted in characters.
Yes. Use ALTER TABLE ... ALTER COLUMN ... SET DATA TYPE VARCHARACTER(new_size). Shortening the size requires checking that no existing value exceeds the new limit.