Skip to content

Character Data Types

Character Data Types#

Character data types are used to store character (alphanumeric) data, meaning words or free-form text, in either the database character set or the national character set.

In Altibase, character data typers comprise the following types:

  • CHAR
  • VARCHAR
  • NCHAR
  • NVARCHAR

CHAR#

Syntax Diagram#

variable_clause::=#

variable_clause

in_row_clause::=#

in_row_clause

Syntax#

CHAR [(size)] [ FIXED | VARIABLE [IN ROW size] ]

Description#

This is a character data type that has a fixed length equal to the specified size. If an input value is shorter than the specified size, the remaining area is filled with blank spaces.

The default size of CHAR column is 1byte, and its maximum length is 32000 bytes.

For more detailed information about the FIXED and VARIABLE clauses, please refer to the "FIXED/VARIABLE OPTIONS" and "IN ROW clauses" section above.

VARCHAR#

Syntax Diagram#

variable_clause::=#

variable_clause

in_row_clause::=#

in_row_clause

Syntax#

VARCHAR [(size)] [ FIXED | VARIABLE [IN ROW size] ]

Description#

This is a character data type for storing alphanumeric data that vary in length within a specified size.

The default size of VARCHAR column is 1byte, and its maximum length is 32000 bytes.

VARCHAR is a variable length data type; that is, when the length of input data is shorter than the specified column size, only the data that were actually inserted are stored. In contrast, for the CHAR data type, if the length of input data is shorter than the column length, the remaining space in the column is padded with blank spaces. For example, if a column is defined as CHAR(10) and the word "magic" is to be stored, it will be stored as "magic_____", where "_" represents a blank space.

For more detailed information about the FIXED and VARIABLE clauses, please refer to the "FIXED/VARIABLE OPTIONS" and "IN ROW clauses" section above.

NCHAR#

Syntax Diagram#

variable_clause::=#

variable_clause

in_row_clause::=#

in_row_clause

Syntax#

NCHAR [(size)] [ FIXED | VARIABLE [IN ROW size] ]

Description#

This is a character data type having a specified fixed length. If an input value is shorter than the specified size, the remainder is filled with blank spaces.

If the national character set is UTF16, the size of one character in an NCHAR column is fixed at 2 bytes, that is, it does not vary in length. In contrast, if the national character set is UTF8, the size of one character in an NCHAR column is not fixed; rather, it varies from 1 to 3 bytes.

The maximum size is 16000 bytes if the national character set is UTF16.

For more detailed information about the FIXED and VARIABLE clauses, please refer to the "FIXED/VARIABLE OPTIONS" and "IN ROW clauses" section above.

NVARCHAR#

Syntax Diagram#

variable_clause::=#

variable_clause

in_row_clause::=#

in_row_clause

Syntax#

NVARCHAR [(size)] [ FIXED | VARIABLE [IN ROW size] ]

Description#

This is a character data type for storing Unicode alphanumeric data that vary in length within a specified size.

If the national character set is UTF16, the size of one character in an NVARCHAR column is fixed at 2 bytes, that is, it does not vary in length. In contrast, if the national character set is UTF8, the size of one character in an NVARCHAR column is not fixed; rather, it varies from 1 to 3 bytes.

In other aspects, the NVARCHAR type is the same as the VARCHAR type, so for more detailed information please refer to the description of the VARCHAR type.

For more detailed information about the FIXED and VARIABLE clauses, please refer to the "FIXED/VARIABLE OPTIONS" and "IN ROW clauses" section above.