CHAR

CHAR provides for fixed-length storage of strings.

Syntax

CHAR[ACTER] [(length)] 

length is an unsigned integer constant. The default length for a CHAR is 1.

Corresponding compile-time Java type

java.lang.String

JDBC metadata type (java.sql.Types)

CHAR

Derby inserts spaces to pad a string value shorter than the expected length. Derby truncates spaces from a string value longer than the expected length. Characters other than spaces cause an exception to be raised. When binary comparison operators are applied to CHARs, the shorter string is padded with spaces to the length of the longer string.

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.

Implementation-defined aspects

The only limit on the length of CHAR data types is the value java.lang.Integer.MAX_VALUE.

-- within a string constant use two single quotation marks
-- to represent a single quotation mark or apostrophe 
VALUES 'hello this is Joe''s string'
Related concepts
Built-In type overview
Numeric types
Related reference
Data type assignments and comparison, sorting, and ordering
BIGINT
BLOB
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
VARCHAR FOR BIT DATA
XML data type