Varchar data type
VARCHAR is a variable-length character-string data type whose values may be subject to a declared maximum length.
Grokking Relational Database Design
VARCHAR is a variable-length SQL character string data type that stores values up to a declared maximum length.
- How it is used
- Guides column-type selection for relatively short character data with varied lengths and an estimable upper limit.
- How deep it goes
- Compares VARCHAR with CHAR and TEXT through storage rationale, selection rules, and a customer-name example.
- Examples
- Uses customer names, state codes, long text, and a manufacturer filter to distinguish VARCHAR from related types.
- What you can do after
- Apply it via SQL by choosing VARCHAR for suitable columns and filtering stored string values with quoted literals.
Read how Grokking Relational Database Design explains varchar data type →
100 SQL Server Mistakes and How to Avoid Them
VARCHAR is a SQL Server variable-length, non-Unicode character data type that stores values using an 8-bit code page unless a UTF-8 collation is applied.
- How it is used
- Uses VARCHAR to size character columns for variable-length address values and to challenge automatic reliance on it.
- How deep it goes
- Explains padding, pages, extents, row slots, and storage metadata, but stops short of a complete storage-cost calculation.
- Examples
- Uses US address fields, maximum place-name lengths, ZIP codes, and a DepartmentCode alteration.
- What you can do after
- Evaluate string-column definitions against value length, padding behavior, and SQL Server storage rather than assuming VARCHAR is always smaller.
Read how 100 SQL Server Mistakes and How to Avoid Them explains varchar data type →
Learn SQL in a Month of Lunches
VARCHAR is a variable-length SQL character data type that stores text using only the space needed for each value.
- How it is used
- Defines variable-length text columns when creating relational database tables.
- How deep it goes
- Explains storage efficiency, maximum lengths, and basic CREATE TABLE usage, while deferring additional table properties.
- Examples
- Uses a category table with CategoryName varchar(20) beside CategoryID int.
- What you can do after
- Build a basic table with a bounded variable-length text column using CREATE TABLE.
Read how Learn SQL in a Month of Lunches explains varchar data type →
DuckDB in Action
The VARCHAR data type represents variable-length character strings.
- How it is used
- Uses VARCHAR as a resilient staging type for SQLite imports and CSV columns requiring deferred interpretation.
- How deep it goes
- Explains VARCHAR as a fallback and demonstrates explicit recasting, but does not discuss storage or execution internals.
- Examples
- Demonstrates mismatched SQLite player fields, CSV inference, and a recast Player view.
- What you can do after
- Operate/configure DuckDB imports by staging values as VARCHAR and casting columns into usable types.
Related concepts
- char(n)alternative to · CHAR(n) is a fixed-length SQL character-string data type whose values occupy the declared character length, typically with trailing-space padding.
- stringkind of · A string is a programming-language value representing an ordered sequence of characters or character units as text.
- variable-length datakind of · Variable-length data is data whose storage size can differ between instances or vary according to the length of its value.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.



