Character string handling in SQL, including VARCHAR and TEXT types.

Store text: CHAR is fixed-length (padded), VARCHAR is variable-length with a limit, TEXT is variable-length with no specified limit. VARCHAR(255) is a common choice for names. Choose based on whether length is predictable and known.

Compatibility

Show:
Database System Support Status Since Version Notes
MySQL ✓ Supported 8.0 MySQL supports standard character types with varying maximum lengths.
PostgreSQL ✓ Supported 9.1 PostgreSQL has a rich set of text handling capabilities including VARCHAR and TEXT types.
SQL Server ✓ Supported 2016 SQL Server supports character types with user-definable maximum lengths and Unicode support.
Oracle ✓ Supported 12c Oracle has flexible text handling capabilities including VARCHAR2 and NVARCHAR2 types.
SQLite ✓ Supported 3.0 TEXT is one of SQLite's five native storage classes and is widely used. SQLite uses dynamic typing — column types are affinities, not strict constraints.

Details

Understanding the differences in how text data is handled across different SQL engines can help developers choose the right tool for their specific needs.

Standard Syntax

Version Support

MySQL: Since 8.0 PostgreSQL: Since 9.1 SQL Server: Since 2016 Oracle: Since 12c SQLite: Since 3.0

Per-Database Syntax & Notes