Using string data types
Hive supports three types of String data type, STRING
, VARCHAR
, and CHAR
:
STRING: It is a sequence of characters that can be expressed using single quotes (
'
) as well as double quotes ("
).VARCHAR: It is variable-length character type. It is defined using a length specifier, which specifies the maximum number of characters allowed in the character string. Its syntax is
VARCHAR(max_length)
. The value of thevarchar
data type gets truncated during processing if necessary to fit within the specified length. While converting the string value to thevarchar
value, if a string value exceeds the length specifier, then the string gets silently truncated. The maximum length ofvarchar
type is65355
.CHAR: It is fixed-length character type. It is defined in the same way as the
varchar
type. If the value is shorter as compared with the specified length, then the value is padded with trailing spaces to achieve the specified length. The maximum length of thechar
type is 255.