Ispirer Website Ispirer Capabilities - MySQL Migration Free Trial

MySQL Data Types - VARCHAR

Versions: MySQL 5.x, 4.x and 3.23

Data Variable-length character data, single-byte and multibyte character sets
Parameters n is the maximum number of characters, optional. CHARACTER SET specifies the character set, COLLATE specifies a collation for the character set.

ASCII is equal to CHARACTER SET latin1, UNICODE is equal to CHARACTER SET ucs2, BINARY is equal to specifying the binary collation
Range 1 ⇐ n ⇐ 65535/charsize (65535 is the maximum row size shared among all columns)
Default n is mandatory
Padding Not right-padded with spaces to n
Trailing Spaces Not removed when the value is stored and retrieved. But trailing spaces are insignificant in comparisons, primary and unique keys
Error Handling Exceeding data truncated and a warning is generated if strict SQL mode is not enabled, otherwise in case of non-space characters truncation, an error is raised

If strict SQL mode is not enabled, a VARCHAR column with a length greater than 65535 is converted to TEXT, otherwise an error is generated
Storage Size Actual entry length
Internals If CHARACTER SET binary is specified, it is automatically converted to the VARBINARY data type without warning
Version Differences MySQL 4.1 and later - CHARACTER SET and COLLATE options are available.
MySQL 4.0.2 and earlier - 1 ⇐ n ⇐ 255
Standards ANSI SQL

MySQL VARCHAR - Equivalents in Other Databases

Database Data Type and Conversion
Oracle VARCHAR2(n), 1 ⇐ n ⇐ 4000/charsize
SQL Server VARCHAR(n | max), 1 ⇐ n ⇐ 8000, 2G if max is specified
PostgreSQL VARCHAR(n), 1 ⇐ n ⇐ 1G
Sybase ASE VARCHAR(n), 1 ⇐ n ⇐ pagesize (2K, 4K, 8K or 16K)
Informix VARCHAR(n,r), 1 ⇐ n ⇐ 255, LVARCHAR(n), 1 ⇐ n ⇐ 32739
HP Neoview VARCHAR(n), 1 ⇐ n ⇐ (32708 - size of other columns)
Ingres VARCHAR(n), 1 ⇐ n ⇐ 32000; TEXT(n), 1 ⇐ n ⇐ 32000

Related Data Types in MySQL

Data Types
Fixed-length character data CHAR(n) NCHAR(n)
Variable-length character data NVARCHAR(n) TINYTEXT TEXT MEDIUMTEXT
Character large objects LONGTEXT

All Data Types

© 1999-2024, Ispirer Systems, LLC. All Rights Reserved.