Product Documentation

SQL Language ElementsData TypesCharacter Data Types

SQL Reference Guide

Previous Topic

Next Topic

Character Data Types

Refer to Character String Literals for details on specifying values to be stored in character columns.

Syntax

char_data_type ::

{ CHARACTER | CHAR } [(length)]

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

| LVARCHAR

Arguments

  • { CHARACTER | CHAR } [(length)] [ CHARACTER SET charset-name ]

    Type CHARACTER (abbreviated as CHAR) corresponds to a null terminated character string with the maximum length specified. The default length is 1. The maximum length is 65,500 bytes (before V12, it was 8,192).

  • LVARCHAR

    The LVARCHAR data type corresponds to an arbitrarily long character string with a maximum length of two gigabytes (2 Gb). The LVARCHAR data type is recommended for CLOB support.

    The arbitrary size and unstructured nature of long data types (LVARCHAR/LVARBINARY) restrict where they can be used.

    • Long columns are allowed in select lists of query expressions and in INSERT and UPDATE statements.
    • INSERT statements can store data from columns of any type except LVARBINARY into a LVARCHAR column, however, LVARCHAR data cannot be stored in any other type.
    • CONTAINS predicates are the only predicates that allow LONG columns.
    • Conditional expressions, arithmetic expressions, and functions cannot specify LONG columns.
    • UPDATE statements cannot specify LONG columns.
  • { CHARACTER VARYING | CHAR VARYING | VARCHAR } [(length)]

    Type CHARACTER VARYING corresponds to a variable-length character string with the maximum length specified.

    • The default length for columns defined as CHARACTER VARYING is 1. In V12 and later, the maximum length is 65,500 (before V12, it was 8,192).

TOCIndex