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
| Database System | Support Status | Since Version | Notes |
|---|---|---|---|
| MySQL | Native | 8.0 | MySQL supports standard character types with varying maximum lengths. |
| PostgreSQL | Native | 9.1 | PostgreSQL has a rich set of text handling capabilities including VARCHAR and TEXT types. |
| SQL Server | Native | 2016 | SQL Server supports character types with user-definable maximum lengths and Unicode support. |
| Oracle | Native | 12c | Oracle has flexible text handling capabilities including VARCHAR2 and NVARCHAR2 types. |
| SQLite | Native | 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: Native since 8.0
PostgreSQL: Native since 9.1
SQL Server: Native since 2016
Oracle: Native since 12c
SQLite: Native since 3.0