VARCHAR

VARCHAR provides for variable-length storage of strings.

Syntax

{ VARCHAR | CHAR VARYING | CHARACTER VARYING }(length) 

length is an unsigned integer constant, and it must not be greater than the constraint of the integer used to specify the length, the value java.lang.Integer.MAX_VALUE.

The maximum length for a VARCHAR string is 32,672 characters.

Corresponding compile-time Java type

java.lang.String

JDBC metadata type (java.sql.Types)

VARCHAR

Derby does not pad a VARCHAR value whose length is less than specified. Derby truncates spaces from a string value when a length greater than the VARCHAR expected is provided. Characters other than spaces are not truncated, and instead cause an exception to be raised. When binary comparison operators are applied to VARCHARs, the lengths of the operands are not altered, and spaces at the end of the values are ignored.

When CHARs and VARCHARs are mixed in expressions, the shorter value is padded with spaces to the length of the longer value.

The type of a string constant is CHAR, not VARCHAR.

Related concepts
Built-In type overview
Numeric types
Related reference
Data type assignments and comparison, sorting, and ordering
BIGINT
BLOB
CHAR
CHAR FOR BIT DATA
CLOB
DATE
DECIMAL
DOUBLE
DOUBLE PRECISION
FLOAT
INTEGER
LONG VARCHAR
LONG VARCHAR FOR BIT DATA
NUMERIC
REAL
SMALLINT
TIME
TIMESTAMP
VARCHAR FOR BIT DATA