Character Data Types
The character data types enable the database server to store text strings.
Element | Description | Restrictions | Syntax |
---|---|---|---|
max | Maximum size in bytes. For VARCHAR and NVARCHAR, this is required. LVARCHAR default is 2048 | VARCHAR and NVARCHAR: Integer; 1 max 255 (or 1 max 254, if indexed) LVARCHAR: 1 max 32,739 | Literal Number |
reserve | Bytes reserved. Default is 0. | Integer; 0 reserve max | Literal Number |
size | Size in bytes. Default is 1. | Integer; 1 size 32,767 | Literal Number |
The database server issues an error if the data type declaration includes empty parentheses, such as LVARCHAR( ). To declare a CHAR or LVARCHAR data type of the default length, simply omit any (size) or (max) specification. The CREATE TABLE statement of Informix® accepts VARCHAR and NVARCHAR column declarations that have no (max) nor (max, reserve) specifications, using ( 1, 0 ) as the (max, reserve) default values for the column.
The following table summarizes the built-in character
data types.
Data Type | Description |
---|---|
CHAR | Stores single-byte or multibyte text strings of fixed length (up to 32,767 bytes); supports code-set order in collation of text data. Default size is 1 byte. |
CHARACTER | Synonym for CHAR |
CHARACTER VARYING | ANSI-compliant synonym for VARCHAR |
LVARCHAR | Stores single-byte or multibyte text strings of varying length (up to 32,739 bytes). The size of other columns in the same table can further reduce this upper limit. Default size is 2,048 bytes. |
NCHAR | Stores single-byte or multibyte text strings of fixed length (up to 32,767 bytes); supports localized collation of text data. |
NVARCHAR | Stores single-byte or multibyte text strings of varying length (up to 255 bytes); supports localized collation of text data. |
VARCHAR | Stores single-byte or multibyte text strings of varying length (up to 255 bytes); supports code-set order collation of text data. |
1 Localized Collation