3. QUEL Data Types : Data Types : Character Data Types : Varchar Data Type
 
Share this page                  
Varchar Data Type
Varchar strings are variable-length strings, stored as a 2-byte (I2) length specifier followed by data. In uncompressed tables, varchar columns occupy their declared length. (If the column is nullable, varchar columns require an additional byte of storage.) For example, if you enter "ABC" into a varchar(5) column, the stored result is:
"03ABCxx"
where "03" is a 2-byte length specifier, "ABC" is three bytes of data, and "xx" represents two bytes containing unknown (and irrelevant) data.
In compressed tables, varchar columns are stripped of trailing data. For example, if you enter "ABC" into a varchar(5) column in a compressed table, the stored result is:
"03ABC"
The varchar data type can contain any character, including non-printing characters and the ASCII null character ("\0").
Blanks are significant in the varchar data type. For example, the following two varchar strings are not considered equal:
"the store is closed"
and
"thestoreisclosed"
If the strings being compared are unequal in length, the shorter string is padded with trailing blanks until it equals the length of the longer string.
For example, consider the following two strings:
"abcd\001"
where "\001" represents one ASCII character (Control-A) and
"abcd"
If they are compared as varchar data types, then
"abcd" > "abcd\001"
because the blank character added to "abcd" to make the strings the same length has a higher value than Control-A ("\040" is greater than "\001").